From 9320b87cc8cf32d0f2f4d1230034ccf252522bb0 Mon Sep 17 00:00:00 2001 From: Perrine Letellier Date: Tue, 14 Jan 2025 11:16:03 +0100 Subject: [PATCH] fix tests but not that well --- data/tests/test_teleicare_history_importer.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/data/tests/test_teleicare_history_importer.py b/data/tests/test_teleicare_history_importer.py index 247964189..e9acacc98 100644 --- a/data/tests/test_teleicare_history_importer.py +++ b/data/tests/test_teleicare_history_importer.py @@ -36,8 +36,8 @@ def setUp(self): Adapted from: https://stackoverflow.com/a/49800437 """ super().setUp() - with connection.schema_editor() as schema_editor: - for table in [IcaEtablissement, IcaComplementAlimentaire, IcaDeclaration, IcaVersionDeclaration]: + for table in [IcaEtablissement, IcaComplementAlimentaire, IcaDeclaration, IcaVersionDeclaration]: + with connection.schema_editor() as schema_editor: schema_editor.create_model(table) if table._meta.db_table not in connection.introspection.table_names(): @@ -46,11 +46,15 @@ def setUp(self): ) def tearDown(self): - super().tearDown() - - with connection.schema_editor() as schema_editor: - for table in [IcaEtablissement, IcaComplementAlimentaire, IcaDeclaration, IcaVersionDeclaration]: - schema_editor.delete_model(table) + # super().tearDown() + for table in [IcaVersionDeclaration, IcaComplementAlimentaire, IcaDeclaration, IcaEtablissement]: + for table_item in table.objects.all(): + table_item.delete() + # la suppression des modèles fail avec l'erreur + # django.db.utils.OperationalError: cannot DROP TABLE "ica_versiondeclaration" because it has pending trigger events + # même avec un sleep(15) + # with connection.schema_editor() as schema_editor: + # schema_editor.delete_model(table) def test_match_companies_on_siret_or_vat(self): """ @@ -120,7 +124,7 @@ def test_create_new_companies(self): self.assertEqual(created_company.postal_code, etablissement_to_create_as_company.etab_adre_cp) self.assertEqual(created_company.city, etablissement_to_create_as_company.etab_adre_ville) - def test_create_declaration(self): + def test_create_declaration_from_history(self): """ Les déclarations sont créées à partir d'object historiques des modèles Ica_ """