diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-07-10 21:17:59 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-07-10 21:17:59 +0200 |
commit | 7b397b211a66672a522fc4e1814df853326e7b55 (patch) | |
tree | 2a83454d3f112a8bbec584853c04f96b61be18d3 /archaeological_files/tests.py | |
parent | e412768a265d572a3bf8c01cb2827e32125ea11d (diff) | |
download | Ishtar-7b397b211a66672a522fc4e1814df853326e7b55.tar.bz2 Ishtar-7b397b211a66672a522fc4e1814df853326e7b55.zip |
Parcel management: copy parcel from file to operation when associating a parcel from the file
Diffstat (limited to 'archaeological_files/tests.py')
-rw-r--r-- | archaeological_files/tests.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/archaeological_files/tests.py b/archaeological_files/tests.py index 312c0402d..f24a29582 100644 --- a/archaeological_files/tests.py +++ b/archaeological_files/tests.py @@ -225,3 +225,29 @@ class FileOperationTest(TestCase, OperationInitTest, FileInit): # parcel owner well attached q = ParcelOwner.objects.filter(parcel__associated_file=self.item) self.assertEqual(q.count(), 1) + + # when attaching parcel from a file to an operation, copy is done + parcel = Parcel.objects.create(parcel_number='42', + section='ZZ', + town=default_town, + associated_file=self.item) + ParcelOwner.objects.create( + owner=self.extra_models['person'], + parcel=parcel, start_date=datetime.date.today(), + end_date=datetime.date.today()) + parcel.operation = self.operation + parcel.save() + # double reference to operation and associated_file is deleted + self.assertEqual(parcel.operation, None) + # now 2 objects with the same parameters + q = Parcel.objects.filter(parcel_number='42', section='ZZ', + town=default_town) + self.assertEqual(q.count(), 2) + q = q.filter(operation=self.operation, associated_file=None) + self.assertEqual(q.count(), 1) + # parcel owner well attached + q = ParcelOwner.objects.filter(parcel__operation=self.operation, + parcel__parcel_number='42') + self.assertEqual(q.count(), 1) + + |