+
+
+
acta
+
+
+ Description
+
+
+
+ The Anti-Counterfeiting Trade agreement is a really bad thing, we would like to kill it with fire.
+
+
+
+ Links
+
+
+
+
+ Dossiers
+
+
+
+
+ Proposals
+
+
+
+
+ Positions
+
+
+
+
+
+ Representative
+ |
+
+ Date
+ |
+
+ Position
+ |
+
+ Link
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/memopol/tests/response_fixtures/ThemesTest.test_theme_detail.metadata b/memopol/tests/response_fixtures/ThemesTest.test_theme_detail.metadata
new file mode 100644
index 0000000000000000000000000000000000000000..a2e0a6921bc4a7d94e1887a6eab7a49889fc3ace
--- /dev/null
+++ b/memopol/tests/response_fixtures/ThemesTest.test_theme_detail.metadata
@@ -0,0 +1,3 @@
+{
+ "status_code": 200
+}
\ No newline at end of file
diff --git a/memopol/tests/response_fixtures/ThemesTest.test_theme_list.content b/memopol/tests/response_fixtures/ThemesTest.test_theme_list.content
new file mode 100644
index 0000000000000000000000000000000000000000..624b22f0ca116dbdac15b379309ca3f1e88758eb
--- /dev/null
+++ b/memopol/tests/response_fixtures/ThemesTest.test_theme_list.content
@@ -0,0 +1,264 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
No matching themes found :(
+
+
+
+
+
+
+
+
+
+
+
diff --git a/memopol/tests/response_fixtures/ThemesTest.test_theme_search_noresults.metadata b/memopol/tests/response_fixtures/ThemesTest.test_theme_search_noresults.metadata
new file mode 100644
index 0000000000000000000000000000000000000000..a2e0a6921bc4a7d94e1887a6eab7a49889fc3ace
--- /dev/null
+++ b/memopol/tests/response_fixtures/ThemesTest.test_theme_search_noresults.metadata
@@ -0,0 +1,3 @@
+{
+ "status_code": 200
+}
\ No newline at end of file
diff --git a/memopol/tests/test_themes.py b/memopol/tests/test_themes.py
new file mode 100644
index 0000000000000000000000000000000000000000..49fb078bf0e760942240b6c5b90cf24a7bfe9d39
--- /dev/null
+++ b/memopol/tests/test_themes.py
@@ -0,0 +1,57 @@
+# -*- coding: utf8 -*-
+
+from django.test import TestCase
+
+from memopol_themes.models import Theme
+
+from .base import ResponseDiffMixin
+
+
+class ThemesTest(ResponseDiffMixin, TestCase):
+ fixtures = ['smaller_sample.json']
+
+ def test_theme_list(self):
+ # session setup
+ self.client.get('/theme/')
+
+ # 1 query for theme count
+ # 1 query for themes
+ self.responsediff_test('/theme/', 2)
+
+ def test_theme_search(self):
+ # session setup
+ self.client.get('/theme/')
+
+ # 1 query for theme count
+ # 1 query for themes
+ q = 'acta'
+ self.responsediff_test('/theme/?search=%s' % q, 2)
+
+ def test_theme_search_noresults(self):
+ # session setup
+ self.client.get('/theme/')
+
+ # 1 query for theme count
+ # nothing else since count = 0
+ q = 'no-theme-will-have-that-title-ever'
+ self.responsediff_test('/theme/?search=%s' % q, 1)
+
+ def test_theme_detail(self):
+ # Get 1st theme in dataset
+ theme = Theme.objects.order_by('pk')[0]
+
+ # session setup
+ self.client.get('/theme/%s/' % theme.pk)
+
+ # 1 query for the theme
+ # 1 query for links
+ # 1 query for dossiers
+ # 1 query for dossier documents
+ # 1 query for dossier document chambers
+ # 1 query for proposals
+ # 1 query for proposals dossiers
+ # 1 query for proposals dossier documents
+ # 1 query for proposals dossier document chambers
+ # 1 query for positions
+ # 1 query for position representativs
+ self.responsediff_test('/theme/%s/' % theme.slug, 11)
diff --git a/memopol/urls.py b/memopol/urls.py
index 848cb768ba9f5f24caf1faa7eba52e6571a14767..57d4c113783948e6362e00e0551c8c828b9e255d 100644
--- a/memopol/urls.py
+++ b/memopol/urls.py
@@ -11,6 +11,8 @@ from views.group_list import GroupList
from views.representative_detail import RepresentativeDetail
from views.representative_list import RepresentativeList
from views.redirects import RedirectGroupList, RedirectGroupRepresentativeList
+from views.theme_detail import ThemeDetail
+from views.theme_list import ThemeList
import api
@@ -84,6 +86,16 @@ urlpatterns = [
ProposalAutocomplete.as_view(),
name='proposal-autocomplete',
),
+ url(
+ r'^theme/$',
+ ThemeList.as_view(),
+ name='theme-list'
+ ),
+ url(
+ r'^theme/(?P