Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jun 10, 2024
1 parent 4fd36c6 commit c14acf4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lemarche/siaes/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def siaes(self, create, extracted, **kwargs):
class SiaeFactory(DjangoModelFactory):
class Meta:
model = Siae
skip_postgeneration_save = True

name = factory.Faker("company", locale="fr_FR")
# slug auto-generated
Expand Down
24 changes: 24 additions & 0 deletions lemarche/siaes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,30 @@ def test_geo_range_in_perimeter_list(self):
)


class SiaeHistoryTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.siae_1 = SiaeFactory(name="ZZZ", brand="ABC")
cls.siae_2 = SiaeFactory(name="Test", brand="")

def test_history_object_on_create(self):
self.assertEqual(self.siae_1.history.count(), 1)
siae_1_create_history_item = self.siae_1.history.last()
self.assertEqual(siae_1_create_history_item.history_type, "+")
self.assertEqual(siae_1_create_history_item.name, self.siae_1.name)

def test_history_object_on_update(self):
self.siae_2.brand = "test"
self.siae_2.save()
self.assertEqual(self.siae_2.history.count(), 1 + 1)
siae_2_create_history_item = self.siae_2.history.last()
self.assertEqual(siae_2_create_history_item.history_type, "+")
self.assertEqual(siae_2_create_history_item.brand, "")
siae_2_update_history_item = self.siae_2.history.first()
self.assertEqual(siae_2_update_history_item.history_type, "~")
self.assertEqual(siae_2_update_history_item.brand, self.siae_2.brand)


class SiaeLabelModelTest(TestCase):
@classmethod
def setUpTestData(cls):
Expand Down

0 comments on commit c14acf4

Please sign in to comment.