summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/tests.py28
-rw-r--r--archaeological_operations/tests/MCC-parcelles-example.csv1
2 files changed, 18 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
diff --git a/archaeological_operations/tests/MCC-parcelles-example.csv b/archaeological_operations/tests/MCC-parcelles-example.csv
index 4104124b5..2d80854f0 100644
--- a/archaeological_operations/tests/MCC-parcelles-example.csv
+++ b/archaeological_operations/tests/MCC-parcelles-example.csv
@@ -1,3 +1,4 @@
code OA,numero INSEE commune,identifiant parcelle,numero parcelle,section cadastre,annee cadastre,nom commune,nom departement,lieu dit adresse
4200,75101,XXXX,42,ZX,,Paris,Ile-de-France,1 rue de l'Église
4200,59350,YY55,55,YY,,Lille,Nord,Patis du tertre
+4201,59350,YY55,55,YY,,Lille,Nord,Patis du tertre