diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-09 23:08:51 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-09 23:08:51 +0100 | 
| commit | c2d86b659a9ad00b1e2cb0485e1310504c8fd03c (patch) | |
| tree | d95d1ca9e9971b465f235cbb86091cd2cf3c7325 /archaeological_operations/tests.py | |
| parent | 1c381564ea9ed133f73e0b330468b204e7a034f1 (diff) | |
| parent | 53f0a5c95c34c0db67528422583dc3e90f20f705 (diff) | |
| download | Ishtar-c2d86b659a9ad00b1e2cb0485e1310504c8fd03c.tar.bz2 Ishtar-c2d86b659a9ad00b1e2cb0485e1310504c8fd03c.zip | |
Merge branch 'master' into v0.9
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 52 | 
1 files changed, 36 insertions, 16 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 23c32434b..1b64f581d 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -298,35 +298,54 @@ class ImportOperationTest(ImportTest, TestCase):          impt.importation()          # new parcels has now been imported          current_nb = models.Parcel.objects.count() -        self.assertEqual(current_nb, old_nb + 2) +        self.assertEqual(current_nb, old_nb + 3)          # and well imported -        last_parcels = models.Parcel.objects.order_by('-pk').all()[0:2] -        external_ids = sorted(['4200-59350-YY55', '4200-75101-XXXX']) -        parcel_numbers = sorted(['42', '55']) -        sections = sorted(['ZX', 'YY']) +        last_parcels = models.Parcel.objects.order_by('-pk').all()[0:3] +        external_ids = sorted(['4200-59350-YY55', '4200-75101-XXXX', +                               '4201-59350-YY55']) +        parcel_numbers = sorted(['42', '55', '55']) +        sections = sorted(['ZX', 'YY', 'YY'])          self.assertEqual(external_ids,                           sorted([p.external_id for p in last_parcels]))          self.assertEqual(parcel_numbers,                           sorted([p.parcel_number for p in last_parcels]))          self.assertEqual(sections,                           sorted([p.section for p in last_parcels])) -        last_ope = models.Operation.objects.order_by('-pk').all()[0] -        towns_ope = last_ope.towns.all() +        ope1 = models.Operation.objects.filter(code_patriarche=4200).all()[0] +        towns_ope = ope1.towns.all()          imported = [imp for acc, imp in impt.get_all_imported()]          for p in last_parcels:              self.assertTrue(p.town in towns_ope)              self.assertTrue(p in imported)          self.assertEqual(len(imported), len(last_parcels)) -        self.assertEqual(models.Parcel.objects.get(parcel_number='55', -                                                   section='YY').external_id, -                         '4200-59350-YY55') +        self.assertEqual( +            models.Parcel.objects.get( +                parcel_number='55', section='YY', +                operation_id=ope1.pk).external_id, +            '4200-59350-YY55') +        # cached_label update +        ope2 = models.Operation.objects.filter(code_patriarche=4201).all()[0] +        self.assertIn('LILLE', ope2.cached_label.upper())          # delete associated parcel with the import deletion          parcel_count = models.Parcel.objects.count()          impt.delete() -        self.assertEqual(parcel_count - 2, models.Parcel.objects.count()) +        self.assertEqual(parcel_count - 3, models.Parcel.objects.count()) + + +class ParcelTest(ImportTest, 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/test_towns.json', +                settings.ROOT_PATH + +                '../ishtar_common/fixtures/initial_importtypes-fr.json', +                settings.ROOT_PATH + +                '../archaeological_operations/fixtures/initial_data-fr.json'] -    def testParseParcels(self): +    def test_parse_parcels(self):          # the database needs to be initialised before importing          from archaeological_operations.import_from_csv import parse_parcels          # default_town = Town.objects.create(numero_insee="12345", @@ -875,17 +894,18 @@ class OperationSearchTest(TestCase, OperationInitTest):          self.operations += self.create_operation(self.alt_user, self.orgas[0])          self.item = self.operations[0] -    def testBaseSearch(self): +    def test_base_search(self):          c = Client()          response = c.get(reverse('get-operation'), {'year': '2010'}) -        # no result when no authentification +        # no result when no authentication          self.assertTrue(not json.loads(response.content))          c.login(username=self.username, password=self.password)          response = c.get(reverse('get-operation'), {'year': '2010'}) -        self.assertTrue(json.loads(response.content)['total'] == 2) +        self.assertEqual(json.loads(response.content)['total'], 2)          response = c.get(reverse('get-operation'),                           {'operator': self.orgas[0].pk}) -        self.assertTrue(json.loads(response.content)['total'] == 2) +        result = json.loads(response.content) +        self.assertEqual(result['total'], 2)      def create_relations(self):          rel1 = models.RelationType.objects.create( | 
