Skip to content

Commit

Permalink
fix tests but not that well
Browse files Browse the repository at this point in the history
  • Loading branch information
Perrine Letellier committed Jan 14, 2025
1 parent 66143ac commit 9320b87
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions data/tests/test_teleicare_history_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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_
"""
Expand Down

0 comments on commit 9320b87

Please sign in to comment.