Skip to content

Commit

Permalink
feat(SIAE): nouvelle property is_live (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn authored Feb 29, 2024
1 parent 57a6093 commit 019cac8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,10 @@ def save(self, *args, **kwargs):
else:
raise e

@property
def is_live(self) -> bool:
return self.is_active and not self.is_delisted

@property
def kind_is_esat_or_ea_or_eatt(self) -> bool:
return self.kind in [siae_constants.KIND_ESAT, siae_constants.KIND_EA, siae_constants.KIND_EATT]
Expand Down
13 changes: 11 additions & 2 deletions lemarche/siaes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ def test_str(self):
siae = SiaeFactory(name="Ma boite")
self.assertEqual(str(siae), "Ma boite")

def test_is_live(self):
siae_live = SiaeFactory(is_active=True, is_delisted=False)
siae_not_live_1 = SiaeFactory(is_active=True, is_delisted=True)
siae_not_live_2 = SiaeFactory(is_active=False, is_delisted=False)
siae_not_live_3 = SiaeFactory(is_active=False, is_delisted=True)
self.assertTrue(siae_live.is_live)
for s in [siae_not_live_1, siae_not_live_2, siae_not_live_3]:
self.assertFalse(s.is_live)

def test_name_display_property(self):
siae_without_brand = SiaeFactory(name="Ma raison sociale")
siae_with_brand = SiaeFactory(name="Ma raison sociale", brand="Mon enseigne")
Expand Down Expand Up @@ -408,10 +417,10 @@ def setUpTestData(cls):
pass

def test_is_live_queryset(self):
SiaeFactory(is_active=True, is_delisted=True)
SiaeFactory(is_active=False, is_delisted=True)
SiaeFactory(is_active=True, is_delisted=False) # live
SiaeFactory(is_active=True, is_delisted=True)
SiaeFactory(is_active=False, is_delisted=False)
SiaeFactory(is_active=False, is_delisted=True)
self.assertEqual(Siae.objects.count(), 4)
self.assertEqual(Siae.objects.is_live().count(), 1)
self.assertEqual(Siae.objects.is_not_live().count(), 3)
Expand Down

0 comments on commit 019cac8

Please sign in to comment.