diff options
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 61e7695f9..bec490122 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -28,7 +28,7 @@ from django.test import TestCase from django.contrib.auth.models import User import models -from ishtar_common.models import OrganizationType, Organization +from ishtar_common.models import OrganizationType, Organization, Town class ImportOperationTest(TestCase): fixtures = ['../ishtar_common/fixtures/initial_data.json', @@ -51,3 +51,69 @@ class ImportOperationTest(TestCase): """ call_command('import_operations', os.sep.join([os.getcwd(), '..', 'archaeological_operations', 'tests', 'sample.csv'])) + + def testParseParcels(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", + name="default_town") + test_values = ( + ("1996 : XT:53,54,56,57,59,60,61,62", + {1996:[ + ("XT", "53"), + ("XT", "54"), + ("XT", "56"), + ("XT", "57"), + ("XT", "59"), + ("XT", "60"), + ("XT", "61"), + ("XT", "62"), + ]}), + ("AD:23", + {None:[ + ("AD", "23") + ]}), + ("1961 :B1:227;", {} + ),("1982 CV:35;CV:36", {} + ),("E:24;E:25", {} + ),("B : 375, 376, 386, 387, 645, 646 / C : 412 à 415, 432 à 435, 622 / F : 120, 149, 150, 284, 287, 321 à 323", {} + ),("AD : 95, 96, 86, 87, 81, 252, AE : 58, AD : 115 à 132", {} + ),("XD:1 à 13, 24 à 28, 33 à 39, 50 à 52, 80, 83, 84 à 86, 259 à 261, 182, 225 ; XH:5 ; P:1640, 1888, 1889, 1890 ; R:1311, 1312, 1314, 1342, 1343, 1559 à 1569", {} + ),("BZ:2 à 5, 365 ; CD:88 à 104, 106, 108, 326", {} + ),("AV 118 à 125, 127, 132 à 137, 153, 398p, 399, 402; BI 27, 30, 32, 33, 188, 255, 256 à 258, 260, 284p, 294; BL 297", {} + ),("A : 904 à 906, 911 ; E:40, 41", {} + ),("1991 : BE:8, 12", {} + ),("AB 37 et 308", {} + ),("1979 : EM:1", {} + ),("B:448;B:449;B:450;B:451;B:452;B:455;B:456;B:457;B:458;B:459;B:1486;", {} + ),("AC : 72 à 81, 91 à 100, 197 / ZC:180 à 189", {} + ),("A : 1195, 1203 à 1208, 1338 ; ZC : 11 à 13, 16, 18, 22, 23, 25 à 31, 45, 82, 103, 107, 109 ; ZA : 2 à 8, 10, 11, 34 à 36, 49 à 41, 57, 58, Z:21", {} + ),("1983 D2 n° 458 et 459", {} + ),("ZS : 21p, 66", {} + ),("VV:166, 167, domaine public", {} + ),("Domaine public", {} + ),("Tranche 1 : AV:4 à 6, 18, 80, 104 / partiellement : 5 et 18", {} + ),(" AS:13 à 15, 17 à 19, 21 à 32, 34 à 45, 47 à 53, 69, 70, 82, 84 / CK:1, 24, 25, 29, 30, 37 à 43", {} + ),(" ZE, 16, 17, 83, 10, 18, 82, 9, 73, 76, 77, 79, 80, 84, 78 et 81", {} + ),(" ZN:37, 15, 35, 28, 29 / ZM:9, 73", {} + ),("A:26a, 26b, 27 / AB:95 / AK:4, 12, 20", {} + ),(" Tranche n°1 : YP:243, 12, 14 à 16, 18 à 26, DP / Tranche n°2 : YP:17, 307, 27, 308, 44 à 46, 683, BM:1, 250, 488 à 492", {} + ),(" 1987 : ZD: ?", {} + ),(" H : 106, 156, 158", {} + )) + for value, result in test_values: + parcels = parse_parcels("12345", value, None) + """ + self.assertTrue(parcels != []) + parcels_copy = parcels[:] + for year in result.keys(): + for parcel in parcels_copy: + if parcel.year != year: + continue + self.assertTrue((parcel.section, parcel.parcel_number) + in result[year]) + parcel.pop(parcel.index(parcel)) + # all parcels have been imported + self.assertEqual(parcels, []) + """ + |