diff --git a/taric_parsers/importer.py b/taric_parsers/importer.py index 34e138c40..26fd9b0eb 100644 --- a/taric_parsers/importer.py +++ b/taric_parsers/importer.py @@ -229,32 +229,6 @@ def commit_changes_from_message( message.taric_object.issues.append(report_item) - def find_object_in_import( - self, - current_transaction, - identity_fields: dict, - object_type, - ): - match = None - - for transaction in self.parsed_transactions: - for message in transaction.parsed_messages: - if message.object_type == object_type: - # check keys - key_match = True - for key in identity_fields.keys(): - if getattr(message.taric_object, key) != identity_fields[key]: - key_match = False - - if key_match: - return message.taric_object - - return match - - def print_stats(self, update_stats: dict): - for key in update_stats.keys(): - print(f"{key} : {update_stats[key]}") - @property def status(self): if len(self.issues("ERROR")) > 0: @@ -595,95 +569,6 @@ def validate_update_type_for(self, parsed_message, parsed_transaction): parsed_message.taric_object.issues.append(report_item) - def _verify_link( - self, - verifying_taric_object: BaseTaricParser, - link_data: ModelLink, - ): - # verify either that the object exists on TAP or in current, previous transactions of current import - kwargs = {} - for field in link_data.fields: - kwargs[field.object_field_name] = getattr( - verifying_taric_object, - field.parser_field_name, - ) - - # check database - db_result = link_data.model.objects.latest_approved().filter(**kwargs) - xml_result = [] - - for transaction in self.parsed_transactions: - for taric_object in transaction.taric_objects: - # check transaction ID - only want to check ones that are less than current verifying object - if taric_object.transaction_id > verifying_taric_object.transaction_id: - continue - - match = False - if taric_object.xml_object_tag == link_data.xml_tag_name: - # ok we have matched the type - now check property - int_match = True - for field in link_data.fields: - if getattr( - verifying_taric_object, - field.parser_field_name, - ) != getattr( - taric_object, - field.object_field_name, - ): - int_match = False - - if int_match: - match = True - if match: - xml_result.append(taric_object) - - # verify that there is only one match, otherwise it's wrong - record_match_count = db_result.count() + len(xml_result) - if record_match_count == 1: - return True - elif record_match_count > 1: - self.create_issue_report_item( - verifying_taric_object, - link_data, - "Multiple matches for possible related taric object", - ) - - return False - - self.create_issue_report_item( - verifying_taric_object, - link_data, - "No matches for possible related taric object", - ) - - return False - - def create_issue_report_item( - self, - target_taric_object: BaseTaricParser, - link_data, - description, - ): - identity_keys = {} - - for field in link_data.fields: - identity_keys[field.object_field_name] = getattr( - target_taric_object, - field.parser_field_name, - ) - - report_item = ImportIssueReportItem( - target_taric_object.xml_object_tag, - link_data.xml_tag_name, - identity_keys, - description, - taric_change_type=target_taric_object.update_type_name, - object_details=str(target_taric_object), - transaction_id=target_taric_object.transaction_id, - ) - - target_taric_object.issues.append(report_item) - def issues(self, filter_by_issue_type: str = None): issues = [] for transaction in self.parsed_transactions: diff --git a/taric_parsers/parsers/measure_parser.py b/taric_parsers/parsers/measure_parser.py index ce57c1cff..c67af2319 100644 --- a/taric_parsers/parsers/measure_parser.py +++ b/taric_parsers/parsers/measure_parser.py @@ -182,6 +182,7 @@ class NewMeasurementUnitQualifierDescriptionParser(Writable, BaseTaricParser): "code", ] + deletes_allowed = False code: str = None # language_id: str = None description: str = None @@ -283,6 +284,8 @@ class NewMonetaryUnitDescriptionParser(Writable, BaseTaricParser): "code", ] + deletes_allowed = False + code: str = None # language_id: str = None description: str = None diff --git a/taric_parsers/parsers/regulation_parser.py b/taric_parsers/parsers/regulation_parser.py index 7abf71ff6..2315654ee 100644 --- a/taric_parsers/parsers/regulation_parser.py +++ b/taric_parsers/parsers/regulation_parser.py @@ -58,6 +58,7 @@ class NewRegulationGroupDescriptionParser(Writable, BaseTaricParser): "group_id", ] + deletes_allowed = False group_id: str = None # language_id: str = None description: str = None diff --git a/taric_parsers/tests.py b/taric_parsers/tests.py deleted file mode 100644 index a39b155ac..000000000 --- a/taric_parsers/tests.py +++ /dev/null @@ -1 +0,0 @@ -# Create your tests here. diff --git a/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_DELETE.xml b/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_DELETE.xml new file mode 100644 index 000000000..bb41caaca --- /dev/null +++ b/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 1 + 210 + 00 + 3 + 2 + + XXX + 2021-01-11 + 2022-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_qualifier_DELETE.xml b/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_qualifier_DELETE.xml new file mode 100644 index 000000000..cbc47d2fc --- /dev/null +++ b/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_qualifier_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 1 + 215 + 00 + 3 + 2 + + A + 2021-01-11 + 2022-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_qualifier_description_DELETE.xml b/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_qualifier_description_DELETE.xml new file mode 100644 index 000000000..ba2eb091a --- /dev/null +++ b/taric_parsers/tests/measure_parsers/importer_examples/measurement_unit_qualifier_description_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 1 + 215 + 05 + 3 + 2 + + A + ZZ + Some Description with changes + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/measure_parsers/importer_examples/monetary_unit_DELETE.xml b/taric_parsers/tests/measure_parsers/importer_examples/monetary_unit_DELETE.xml new file mode 100644 index 000000000..5ff8a5319 --- /dev/null +++ b/taric_parsers/tests/measure_parsers/importer_examples/monetary_unit_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 1 + 225 + 00 + 3 + 2 + + ZZZ + 2021-01-11 + 2022-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/measure_parsers/importer_examples/monetary_unit_description_DELETE.xml b/taric_parsers/tests/measure_parsers/importer_examples/monetary_unit_description_DELETE.xml new file mode 100644 index 000000000..1f9543ac3 --- /dev/null +++ b/taric_parsers/tests/measure_parsers/importer_examples/monetary_unit_description_DELETE.xml @@ -0,0 +1,23 @@ + + + + + + + 1 + 225 + 05 + 3 + 2 + + ZZZ + zz + Some Description with changes + + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/measure_parsers/test_measurement_unit_parser.py b/taric_parsers/tests/measure_parsers/test_measurement_unit_parser.py index da2230189..902e1ab78 100644 --- a/taric_parsers/tests/measure_parsers/test_measurement_unit_parser.py +++ b/taric_parsers/tests/measure_parsers/test_measurement_unit_parser.py @@ -86,3 +86,11 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert MeasurementUnit.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("measurement_unit_CREATE.xml", __file__, True) + importer = preload_import("measurement_unit_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert MeasurementUnit.objects.all().count() == 2 diff --git a/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_description_parser.py b/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_description_parser.py index 275f58e93..62e61445e 100644 --- a/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_description_parser.py +++ b/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_description_parser.py @@ -92,3 +92,21 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert MeasurementUnitQualifier.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import( + "measurement_unit_qualifier_description_CREATE.xml", + __file__, + True, + ) + importer = preload_import( + "measurement_unit_qualifier_description_DELETE.xml", + __file__, + ) + + assert len(importer.issues()) == 1 + + assert ( + "Children of Taric objects of type MeasurementUnitQualifier can't be deleted directly" + in str(importer.issues()[0]) + ) diff --git a/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_parser.py b/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_parser.py index ff00d0f6d..39e8fced0 100644 --- a/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_parser.py +++ b/taric_parsers/tests/measure_parsers/test_measurement_unit_qualifier_parser.py @@ -86,3 +86,11 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert MeasurementUnitQualifier.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("measurement_unit_qualifier_CREATE.xml", __file__, True) + importer = preload_import("measurement_unit_qualifier_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert MeasurementUnitQualifier.objects.all().count() == 2 diff --git a/taric_parsers/tests/measure_parsers/test_monetary_unit_description_parser.py b/taric_parsers/tests/measure_parsers/test_monetary_unit_description_parser.py index 1f8760836..f1a2c266d 100644 --- a/taric_parsers/tests/measure_parsers/test_monetary_unit_description_parser.py +++ b/taric_parsers/tests/measure_parsers/test_monetary_unit_description_parser.py @@ -82,3 +82,14 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert MonetaryUnit.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("monetary_unit_description_CREATE.xml", __file__, True) + importer = preload_import("monetary_unit_description_DELETE.xml", __file__) + + assert len(importer.issues()) == 1 + + assert ( + "Children of Taric objects of type MonetaryUnit can't be deleted directly" + in str(importer.issues()[0]) + ) diff --git a/taric_parsers/tests/measure_parsers/test_monetary_unit_parser.py b/taric_parsers/tests/measure_parsers/test_monetary_unit_parser.py index 12c82294c..1b5f1b6fe 100644 --- a/taric_parsers/tests/measure_parsers/test_monetary_unit_parser.py +++ b/taric_parsers/tests/measure_parsers/test_monetary_unit_parser.py @@ -86,3 +86,11 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert MonetaryUnit.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("monetary_unit_CREATE.xml", __file__, True) + importer = preload_import("monetary_unit_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert MonetaryUnit.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_association_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_association_DELETE.xml new file mode 100644 index 000000000..ac997d90b --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_association_DELETE.xml @@ -0,0 +1,24 @@ + + + + + + + 19971104 + 370 + 05 + 1 + 2 + + 99 + 100 + EQ + 1.1 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_balance_event_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_balance_event_DELETE.xml new file mode 100644 index 000000000..f9c728320 --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_balance_event_DELETE.xml @@ -0,0 +1,24 @@ + + + + + + + 1 + 375 + 00 + 1 + 2 + + 100 + 2020-09-25T14:58:58 + 10 + 0 + 0 + 2021-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_blocking_period_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_blocking_period_DELETE.xml new file mode 100644 index 000000000..81c4b9d10 --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_blocking_period_DELETE.xml @@ -0,0 +1,26 @@ + + + + + + + 19971104 + 370 + 10 + 1 + 2 + + 22 + 99 + 2021-01-11 + 2022-01-01 + 3 + Some Description with changes + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_closed_and_transferred_event_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_closed_and_transferred_event_DELETE.xml new file mode 100644 index 000000000..53e4d5d75 --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_closed_and_transferred_event_DELETE.xml @@ -0,0 +1,24 @@ + + + + + + + 1 + 375 + 30 + 1 + 2 + + 100 + 2020-09-25T14:58:58 + 2021-01-01 + ZZZ + 123.77 + 56 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_critical_event_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_critical_event_DELETE.xml new file mode 100644 index 000000000..fc8dc86be --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_critical_event_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 1 + 375 + 10 + 1 + 2 + + 100 + 2020-09-25T14:58:58 + Y + 2021-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_definition_CREATE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_definition_CREATE.xml index 8e4e13aba..fc5da093d 100644 --- a/taric_parsers/tests/quota_parser/importer_examples/quota_definition_CREATE.xml +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_definition_CREATE.xml @@ -166,7 +166,7 @@ 1 3 - 99 + 100 054515 7 2023-01-01 diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_definition_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_definition_DELETE.xml new file mode 100644 index 000000000..554d8513b --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_definition_DELETE.xml @@ -0,0 +1,32 @@ + + + + + + + 19971104 + 370 + 00 + 1 + 2 + + 99 + 054515 + 7 + 2023-01-11 + 2024-01-01 + 1200 + 200 + ZZZ + 3 + 0 + 75 + Some Description with changes + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_definition_UPDATE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_definition_UPDATE.xml index 2093359e9..1b2c3e0a1 100644 --- a/taric_parsers/tests/quota_parser/importer_examples/quota_definition_UPDATE.xml +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_definition_UPDATE.xml @@ -12,7 +12,7 @@ 1 1 - 99 + 100 054515 7 2023-01-11 diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_exhaustion_event_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_exhaustion_event_DELETE.xml new file mode 100644 index 000000000..9279a6ffc --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_exhaustion_event_DELETE.xml @@ -0,0 +1,21 @@ + + + + + + + 1 + 375 + 15 + 1 + 2 + + 100 + 2020-09-25T14:58:58 + 2021-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_DELETE.xml new file mode 100644 index 000000000..65747988f --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_DELETE.xml @@ -0,0 +1,23 @@ + + + + + + + 19971104 + 360 + 00 + 1 + 2 + + 7 + 054515 + 2021-01-11 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_origin_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_origin_DELETE.xml new file mode 100644 index 000000000..7386a8c17 --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_origin_DELETE.xml @@ -0,0 +1,26 @@ + + + + + + + 19971104 + 360 + 10 + 1 + 2 + + 123 + 7 + AB01 + 8 + 2021-01-11 + 2022-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_origin_exclusion_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_origin_exclusion_DELETE.xml new file mode 100644 index 000000000..6e30b395c --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_order_number_origin_exclusion_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 19971104 + 360 + 15 + 1 + 2 + + 123 + 8 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_reopening_event_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_reopening_event_DELETE.xml new file mode 100644 index 000000000..cc33a29db --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_reopening_event_DELETE.xml @@ -0,0 +1,21 @@ + + + + + + + 1 + 375 + 20 + 1 + 2 + + 100 + 2020-09-25T14:58:58 + 2021-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_suspension_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_suspension_DELETE.xml new file mode 100644 index 000000000..c33726fd0 --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_suspension_DELETE.xml @@ -0,0 +1,25 @@ + + + + + + + 19971104 + 370 + 15 + 1 + 2 + + 123 + 99 + 2021-01-11 + 2022-01-01 + Some Description with changes + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_unblocking_event_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_unblocking_event_DELETE.xml new file mode 100644 index 000000000..0a4787fa8 --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_unblocking_event_DELETE.xml @@ -0,0 +1,21 @@ + + + + + + + 1 + 375 + 05 + 1 + 2 + + 100 + 2020-09-25T14:58:58 + 2021-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/importer_examples/quota_unsuspension_event_DELETE.xml b/taric_parsers/tests/quota_parser/importer_examples/quota_unsuspension_event_DELETE.xml new file mode 100644 index 000000000..cbede4d0f --- /dev/null +++ b/taric_parsers/tests/quota_parser/importer_examples/quota_unsuspension_event_DELETE.xml @@ -0,0 +1,21 @@ + + + + + + + 1 + 375 + 25 + 1 + 2 + + 100 + 2020-09-25T14:58:58 + 2021-01-01 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/quota_parser/test_quota_association_parser.py b/taric_parsers/tests/quota_parser/test_quota_association_parser.py index 57c9e49b9..7232defff 100644 --- a/taric_parsers/tests/quota_parser/test_quota_association_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_association_parser.py @@ -90,3 +90,11 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert QuotaAssociation.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("quota_association_CREATE.xml", __file__, True) + importer = preload_import("quota_association_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaAssociation.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_balance_event_parser.py b/taric_parsers/tests/quota_parser/test_quota_balance_event_parser.py index d339474c1..069519912 100644 --- a/taric_parsers/tests/quota_parser/test_quota_balance_event_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_balance_event_parser.py @@ -114,3 +114,12 @@ def test_import_update(self, superuser): assert "Taric objects of type QuotaEvent can't be updated" in str( importer.issues()[0], ) + + def test_import_delete(self, superuser): + # No Updates for this object type + preload_import("quota_balance_event_CREATE.xml", __file__, True) + importer = preload_import("quota_balance_event_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaEvent.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_blocking_parser.py b/taric_parsers/tests/quota_parser/test_quota_blocking_parser.py index dd4e7b076..339c34c73 100644 --- a/taric_parsers/tests/quota_parser/test_quota_blocking_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_blocking_parser.py @@ -102,3 +102,11 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert QuotaBlocking.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("quota_blocking_period_CREATE.xml", __file__, True) + importer = preload_import("quota_blocking_period_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaBlocking.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_closed_and_transferred_event_parser.py b/taric_parsers/tests/quota_parser/test_quota_closed_and_transferred_event_parser.py index da294b468..829822418 100644 --- a/taric_parsers/tests/quota_parser/test_quota_closed_and_transferred_event_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_closed_and_transferred_event_parser.py @@ -127,3 +127,18 @@ def test_import_update(self, superuser): assert "Taric objects of type QuotaEvent can't be updated" in str( importer.issues()[0], ) + + def test_import_delete(self, superuser): + preload_import( + "quota_closed_and_transferred_event_CREATE.xml", + __file__, + True, + ) + importer = preload_import( + "quota_closed_and_transferred_event_DELETE.xml", + __file__, + ) + + assert len(importer.issues()) == 0 + + assert QuotaEvent.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_critical_event_parser.py b/taric_parsers/tests/quota_parser/test_quota_critical_event_parser.py index c9d707f08..ca0ed637f 100644 --- a/taric_parsers/tests/quota_parser/test_quota_critical_event_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_critical_event_parser.py @@ -104,3 +104,11 @@ def test_import_update(self, superuser): assert "Taric objects of type QuotaEvent can't be updated" in str( importer.issues()[0], ) + + def test_import_delete(self, superuser): + preload_import("quota_critical_event_CREATE.xml", __file__, True) + importer = preload_import("quota_critical_event_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaEvent.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_definition_parser.py b/taric_parsers/tests/quota_parser/test_quota_definition_parser.py index 9b6c03374..6591c2220 100644 --- a/taric_parsers/tests/quota_parser/test_quota_definition_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_definition_parser.py @@ -124,7 +124,7 @@ def test_import(self, superuser): target = target_message.taric_object # check properties - assert target.sid == 99 + assert target.sid == 100 assert target.order_number__order_number == "054515" assert target.valid_between_lower == date(2023, 1, 1) assert target.valid_between_upper == date(2024, 1, 1) @@ -153,7 +153,7 @@ def test_import_update(self, superuser): target = target_message.taric_object # check properties - assert target.sid == 99 + assert target.sid == 100 assert target.order_number__order_number == "054515" assert target.valid_between_lower == date(2023, 1, 11) assert target.valid_between_upper == date(2024, 1, 1) @@ -168,4 +168,14 @@ def test_import_update(self, superuser): assert target.quota_critical_threshold == 75 assert target.description == "Some Description with changes" + assert importer.issues() == [] + + assert QuotaDefinition.objects.all().count() == 3 + + def test_import_delete(self, superuser): + preload_import("quota_definition_CREATE.xml", __file__, True) + importer = preload_import("quota_definition_DELETE.xml", __file__) + + assert importer.issues() == [] + assert QuotaDefinition.objects.all().count() == 3 diff --git a/taric_parsers/tests/quota_parser/test_quota_exhaustion_event_parser.py b/taric_parsers/tests/quota_parser/test_quota_exhaustion_event_parser.py index 3fd36da44..7eef5eac6 100644 --- a/taric_parsers/tests/quota_parser/test_quota_exhaustion_event_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_exhaustion_event_parser.py @@ -96,3 +96,11 @@ def test_import_update(self, superuser): assert "Taric objects of type QuotaEvent can't be updated" in str( importer.issues()[0], ) + + def test_import_delete(self, superuser): + preload_import("quota_exhaustion_event_CREATE.xml", __file__, True) + importer = preload_import("quota_exhaustion_event_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaEvent.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_order_number_origin_exclusion_parser.py b/taric_parsers/tests/quota_parser/test_quota_order_number_origin_exclusion_parser.py index afb53b3de..6bcec5e10 100644 --- a/taric_parsers/tests/quota_parser/test_quota_order_number_origin_exclusion_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_order_number_origin_exclusion_parser.py @@ -91,3 +91,18 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert QuotaOrderNumberOriginExclusion.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import( + "quota_order_number_origin_exclusion_CREATE.xml", + __file__, + True, + ) + importer = preload_import( + "quota_order_number_origin_exclusion_DELETE.xml", + __file__, + ) + + assert len(importer.issues()) == 0 + + assert QuotaOrderNumberOriginExclusion.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_order_number_origin_parser.py b/taric_parsers/tests/quota_parser/test_quota_order_number_origin_parser.py index a052b76ea..bc6205ee1 100644 --- a/taric_parsers/tests/quota_parser/test_quota_order_number_origin_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_order_number_origin_parser.py @@ -114,3 +114,18 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert QuotaOrderNumberOrigin.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import( + "quota_order_number_origin_CREATE.xml", + __file__, + True, + ) + importer = preload_import( + "quota_order_number_origin_DELETE.xml", + __file__, + ) + + assert len(importer.issues()) == 0 + + assert QuotaOrderNumberOrigin.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_order_number_parser.py b/taric_parsers/tests/quota_parser/test_quota_order_number_parser.py index 47356eb20..54dbf3bca 100644 --- a/taric_parsers/tests/quota_parser/test_quota_order_number_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_order_number_parser.py @@ -93,3 +93,11 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert QuotaOrderNumber.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("quota_order_number_CREATE.xml", __file__, True) + importer = preload_import("quota_order_number_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaOrderNumber.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_reopening_event_parser.py b/taric_parsers/tests/quota_parser/test_quota_reopening_event_parser.py index 813caa0fc..beb28cd25 100644 --- a/taric_parsers/tests/quota_parser/test_quota_reopening_event_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_reopening_event_parser.py @@ -93,3 +93,11 @@ def test_import_update(self, superuser): assert "Taric objects of type QuotaEvent can't be updated" in str( importer.issues()[0], ) + + def test_import_delete(self, superuser): + preload_import("quota_reopening_event_CREATE.xml", __file__, True) + importer = preload_import("quota_reopening_event_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaEvent.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_suspension_parser.py b/taric_parsers/tests/quota_parser/test_quota_suspension_parser.py index 107ffff1a..96819bffa 100644 --- a/taric_parsers/tests/quota_parser/test_quota_suspension_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_suspension_parser.py @@ -97,3 +97,10 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert QuotaSuspension.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import("quota_suspension_CREATE.xml", __file__, True) + importer = preload_import("quota_suspension_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + assert QuotaSuspension.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_unblocking_event_parser.py b/taric_parsers/tests/quota_parser/test_quota_unblocking_event_parser.py index 58131bb5f..183e035a9 100644 --- a/taric_parsers/tests/quota_parser/test_quota_unblocking_event_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_unblocking_event_parser.py @@ -96,3 +96,10 @@ def test_import_update(self, superuser): assert "Taric objects of type QuotaEvent can't be updated" in str( importer.issues()[0], ) + + def test_import_delete(self, superuser): + preload_import("quota_unblocking_event_CREATE.xml", __file__, True) + importer = preload_import("quota_unblocking_event_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + assert QuotaEvent.objects.all().count() == 2 diff --git a/taric_parsers/tests/quota_parser/test_quota_unsuspension_event_parser.py b/taric_parsers/tests/quota_parser/test_quota_unsuspension_event_parser.py index 4fdb24e54..988f316c1 100644 --- a/taric_parsers/tests/quota_parser/test_quota_unsuspension_event_parser.py +++ b/taric_parsers/tests/quota_parser/test_quota_unsuspension_event_parser.py @@ -96,3 +96,11 @@ def test_import_update(self, superuser): assert "Taric objects of type QuotaEvent can't be updated" in str( importer.issues()[0], ) + + def test_import_delete(self, superuser): + preload_import("quota_unsuspension_event_CREATE.xml", __file__, True) + importer = preload_import("quota_unsuspension_event_DELETE.xml", __file__) + + assert len(importer.issues()) == 0 + + assert QuotaEvent.objects.all().count() == 2 diff --git a/taric_parsers/tests/regulation_parsers/importer_examples/base_regulation_DELETE.xml b/taric_parsers/tests/regulation_parsers/importer_examples/base_regulation_DELETE.xml new file mode 100644 index 000000000..83a8f572d --- /dev/null +++ b/taric_parsers/tests/regulation_parsers/importer_examples/base_regulation_DELETE.xml @@ -0,0 +1,33 @@ + + + + + + + 1 + 285 + 00 + 3 + 2 + + 1 + Z0000001 + 2023-01-11 + ABCDE + 7 + 2023-01-11 + 1 + 7 + 0 + Some Info Text with changes + 1 + ABC + 2021-01-11 + 2022-01-11 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/regulation_parsers/importer_examples/regulation_group_DELETE.xml b/taric_parsers/tests/regulation_parsers/importer_examples/regulation_group_DELETE.xml new file mode 100644 index 000000000..3caae8d5f --- /dev/null +++ b/taric_parsers/tests/regulation_parsers/importer_examples/regulation_group_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 1 + 150 + 00 + 3 + 2 + + ABC + 2021-01-11 + 2022-01-11 + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/regulation_parsers/importer_examples/regulation_group_description_DELETE.xml b/taric_parsers/tests/regulation_parsers/importer_examples/regulation_group_description_DELETE.xml new file mode 100644 index 000000000..ae10a1a6c --- /dev/null +++ b/taric_parsers/tests/regulation_parsers/importer_examples/regulation_group_description_DELETE.xml @@ -0,0 +1,22 @@ + + + + + + + 1 + 150 + 05 + 3 + 2 + + ABC + ZZ + Some Description with changes + + + + + + \ No newline at end of file diff --git a/taric_parsers/tests/regulation_parsers/test_base_regulation_parser.py b/taric_parsers/tests/regulation_parsers/test_base_regulation_parser.py index bf004b43a..2996cb2fe 100644 --- a/taric_parsers/tests/regulation_parsers/test_base_regulation_parser.py +++ b/taric_parsers/tests/regulation_parsers/test_base_regulation_parser.py @@ -165,3 +165,18 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert Regulation.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import( + "base_regulation_CREATE.xml", + __file__, + True, + ) + importer = preload_import( + "base_regulation_DELETE.xml", + __file__, + ) + + assert len(importer.issues()) == 0 + + assert Regulation.objects.all().count() == 2 diff --git a/taric_parsers/tests/regulation_parsers/test_regulation_group_description_parser.py b/taric_parsers/tests/regulation_parsers/test_regulation_group_description_parser.py index a6b1dbe3f..6829924d5 100644 --- a/taric_parsers/tests/regulation_parsers/test_regulation_group_description_parser.py +++ b/taric_parsers/tests/regulation_parsers/test_regulation_group_description_parser.py @@ -94,3 +94,21 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert Group.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import( + "regulation_group_description_CREATE.xml", + __file__, + True, + ) + importer = preload_import( + "regulation_group_description_DELETE.xml", + __file__, + ) + + assert len(importer.issues()) == 1 + + assert ( + "Children of Taric objects of type Group can't be deleted directly" + in str(importer.issues()[0]) + ) diff --git a/taric_parsers/tests/regulation_parsers/test_regulation_group_parser.py b/taric_parsers/tests/regulation_parsers/test_regulation_group_parser.py index 811153470..554befa9d 100644 --- a/taric_parsers/tests/regulation_parsers/test_regulation_group_parser.py +++ b/taric_parsers/tests/regulation_parsers/test_regulation_group_parser.py @@ -100,3 +100,19 @@ def test_import_update(self, superuser): assert len(importer.issues()) == 0 assert Group.objects.all().count() == 2 + + def test_import_delete(self, superuser): + preload_import( + "regulation_group_CREATE.xml", + __file__, + True, + ) + + importer = preload_import( + "regulation_group_DELETE.xml", + __file__, + ) + + assert len(importer.issues()) == 0 + + assert Group.objects.all().count() == 2