diff options
Diffstat (limited to 'ishtar_common/tests.py')
| -rw-r--r-- | ishtar_common/tests.py | 33 | 
1 files changed, 28 insertions, 5 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index a4d354eb1..3c46ee6b2 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -1,6 +1,6 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*- -# Copyright (C) 2015 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2015-2016 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet>  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU Affero General Public License as @@ -24,6 +24,7 @@ from django.contrib.auth.models import User  from django.contrib.contenttypes.models import ContentType  from django.core.cache import cache  from django.core.exceptions import ValidationError +from django.core.files.base import File as DjangoFile  from django.core.urlresolvers import reverse  from django.template.defaultfilters import slugify  from django.test import TestCase @@ -216,7 +217,29 @@ class MergeTest(TestCase):                          in self.person_3.person_types.all()) -class ImportKeyTest(TestCase): +class ImportTest(TestCase): +    def testDeleteRelated(self): +        town = models.Town.objects.create(name='my-test') +        self.assertEqual(models.Town.objects.filter(name='my-test').count(), 1) + +        # create an import, fields are not relevant... +        create_user() +        importer_type = models.ImporterType.objects.create( +            associated_models='ishtar_common.models.Person') +        mcc_operation_file = DjangoFile(file( +            settings.ROOT_PATH + +            '../archaeological_operations/tests/MCC-operations-example.csv', +            'rb')) +        imprt = models.Import.objects.create( +            user=models.IshtarUser.objects.all()[0], +            importer_type=importer_type, +            imported_file=mcc_operation_file) + +        town.imports.add(imprt) +        imprt.delete() +        # town should be deleted +        self.assertEqual(models.Town.objects.filter(name='my-test').count(), 0) +      def testKeys(self):          content_type = ContentType.objects.get_for_model(              models.OrganizationType) @@ -291,12 +314,12 @@ class IshtarSiteProfileTest(TestCase):          self.assertTrue(profile2.context_record and profile2.find)      def testDefaultProfile(self): -        cache.set('default-ishtarsiteprofile-is-current-profile', None, +        cache.set('default-ishtar_common-IshtarSiteProfile', None,                    settings.CACHE_TIMEOUT)          self.assertFalse(models.IshtarSiteProfile.objects.count()) -        profile = models.get_current_profile() +        profile = models.get_current_profile(force=True)          self.assertTrue(profile) -        self.assertTrue(models.IshtarSiteProfile.objects.count()) +        self.assertEqual(models.IshtarSiteProfile.objects.count(), 1)      def testMenuFiltering(self):          cache.set('default-ishtarsiteprofile-is-current-profile', None,  | 
