diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-03 20:08:22 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-03 20:14:17 +0100 |
commit | f2de1a673e0686e5d8f03700a64bedef7ccb0ff3 (patch) | |
tree | d13b2f3fbd8bd8491d353dab0055bed66ed98f33 /ishtar_common/tests.py | |
parent | 87970f1e7444a79781c04d720acdea3defc11012 (diff) | |
download | Ishtar-f2de1a673e0686e5d8f03700a64bedef7ccb0ff3.tar.bz2 Ishtar-f2de1a673e0686e5d8f03700a64bedef7ccb0ff3.zip |
Admin: add basic tests for general types
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r-- | ishtar_common/tests.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 90fc3f0f5..458083ac3 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -260,6 +260,52 @@ class CacheTest(TestCase): self.assertFalse('testy' in types) +class AdminGenTypeTest(TestCase): + fixtures = [settings.ROOT_PATH + + '../fixtures/initial_data-auth-fr.json', + settings.ROOT_PATH + + '../ishtar_common/fixtures/initial_data-fr.json', + settings.ROOT_PATH + + '../ishtar_common/fixtures/initial_spatialrefsystem-fr.json', + settings.ROOT_PATH + + '../ishtar_common/fixtures/initial_importtypes-fr.json', + settings.ROOT_PATH + + '../archaeological_operations/fixtures/initial_data-fr.json'] + models = [models.OrganizationType, models.PersonType, models.TitleType, + models.AuthorType, models.SourceType, models.OperationType, + models.SpatialReferenceSystem] + # models.Format, models.SupportType -- need fixtures + module_name = 'ishtar_common' + + def setUp(self): + password = 'mypassword' + my_admin = User.objects.create_superuser( + 'myuser', 'myemail@test.com', password) + self.client = Client() + self.client.login(username=my_admin.username, password=password) + + def test_listing_and_detail(self): + for model in self.models: + # quick test to verify basic access to listing + base_url = '/admin/{}/{}/'.format(self.module_name, + model.__name__.lower()) + url = base_url + response = self.client.get(url) + self.assertEqual( + response.status_code, 200, + msg="Can not access admin list for {}.".format(model)) + url = base_url + "{}/".format(model.objects.all()[0].pk) + response = self.client.get(url) + self.assertEqual( + response.status_code, 200, + msg="Can not access admin detail for {}.".format(model)) + + def test_str(self): + # test __str__ + for model in self.models: + self.assertTrue(str(model.objects.all()[0])) + + class MergeTest(TestCase): def setUp(self): self.user, created = User.objects.get_or_create(username='username') |