diff options
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 40e50f42b..d1c4892bf 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -25,6 +25,7 @@ import tempfile import zipfile from django.conf import settings +from django.contrib.auth.models import Group from django.contrib.contenttypes.models import ContentType from django.core.files.uploadedfile import SimpleUploadedFile from django.core.urlresolvers import reverse @@ -583,7 +584,7 @@ class ParcelTest(ImportTest, TestCase): def test_parse_parcels(self): # the database needs to be initialised before importing - from archaeological_operations.import_from_csv import parse_parcels + from archaeological_operations.utils import parse_parcels # default_town = Town.objects.create(numero_insee="12345", # name="default_town") test_values = ( @@ -1138,27 +1139,26 @@ class OperationTest(TestCase, OperationInitTest): def test_show(self): operation = self.operations[0] - source = models.OperationSource.objects.create( - operation=operation, title="Source title", + source = models.Document.objects.create( + title="Source title", source_type=models.SourceType.objects.all()[0] ) + operation.documents.add(source) c = Client() response = c.get(reverse('show-operation', kwargs={'pk': operation.pk})) self.assertEqual(response.status_code, 200) # empty content when not allowed self.assertEqual(response.content, "") - response = c.get(reverse('show-operationsource', + response = c.get(reverse('show-document', kwargs={'pk': source.pk})) - self.assertEqual(response.status_code, 200) - # empty content when not allowed - self.assertEqual(response.content, "") + self.assertRedirects(response, "/") c.login(username=self.username, password=self.password) response = c.get(reverse('show-operation', kwargs={'pk': operation.pk})) self.assertEqual(response.status_code, 200) self.assertIn('class="card sheet"', response.content) - response = c.get(reverse('show-operationsource', + response = c.get(reverse('show-document', kwargs={'pk': source.pk})) self.assertEqual(response.status_code, 200) self.assertIn('class="card sheet"', response.content) @@ -1582,8 +1582,9 @@ class OperationPermissionTest(TestCase, OperationInitTest): self.alt_username2, self.alt_password2, self.alt_user2 = create_user( username='luke', password='iamyourfather' ) + profile_type = ProfileType.objects.get(txt_idx='collaborator') profile = UserProfile.objects.create( - profile_type=ProfileType.objects.get(txt_idx='collaborator'), + profile_type=profile_type, person=self.alt_user2.ishtaruser.person, current=True ) @@ -1630,13 +1631,13 @@ class OperationPermissionTest(TestCase, OperationInitTest): operation_pk1 = self.operations[0].pk operation_pk2 = self.operations[1].pk + modif_url = '/operation_modification/general-operation_modification' + # no result when no authentification c = Client() response = c.get(reverse('operation_modify', args=[operation_pk2])) self.assertRedirects(response, "/") - modif_url = '/operation_modification/general-operation_modification' - # possession c = Client() c.login(username=self.alt_username, password=self.alt_password) @@ -1649,6 +1650,12 @@ class OperationPermissionTest(TestCase, OperationInitTest): follow=True) self.assertRedirects(response, "/") + profile_type = ProfileType.objects.get(txt_idx='collaborator') + profile_type.groups.add( + Group.objects.get(name=u"Opérations rattachées : " + u"modification/suppression") + ) + # area filter c = Client() c.login(username=self.alt_username2, password=self.alt_password2) @@ -2193,6 +2200,7 @@ class OperationAdminActWizardCreationTest(WizardTest, OperationInitTest, self.number + 1) +""" class OperationSourceWizardModificationTest(WizardTest, OperationInitTest, TestCase): fixtures = FILE_FIXTURES @@ -2239,6 +2247,7 @@ class OperationSourceWizardModificationTest(WizardTest, OperationInitTest, def post_wizard(self): source = models.OperationSource.objects.get(pk=self.source.pk) self.assertEqual(source.authors.count(), 0) +""" class SiteTest(TestCase, OperationInitTest): |