diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-06 20:19:50 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-06 20:20:14 +0100 |
commit | 59494986c1ec1554b590e33ccf39d385893c441c (patch) | |
tree | afa8b0e3b8e9598de2d7931e2a716b80b5fbe598 /archaeological_operations/tests.py | |
parent | 19fbbe13833fa708543efc9672e82c8e0b1039a2 (diff) | |
download | Ishtar-59494986c1ec1554b590e33ccf39d385893c441c.tar.bz2 Ishtar-59494986c1ec1554b590e33ccf39d385893c441c.zip |
Test: label update after parcel import (refs #3460)
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 23c32434b..63f572643 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -298,33 +298,39 @@ 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()) def testParseParcels(self): # the database needs to be initialised before importing |