Exemple #1
0
 def test_is_missing_content_property(self):
     siae_missing = SiaeFactory(name="Ma boite", contact_email="")
     self.assertTrue(siae_missing.is_missing_content)
     siae_full = SiaeFactory(
         name="Ma boite",
         contact_website="https://example.com",
         contact_email="*****@*****.**",
         contact_phone="0000000000",
         description="test",
     )
     siae_full_2 = SiaeFactory(
         name="Ma boite",
         contact_website="https://example.com",
         # contact_email="*****@*****.**",
         # contact_phone="0000000000",
         description="test",
     )
     sector = SectorFactory()
     siae_full.sectors.add(sector)
     SiaeOfferFactory(siae=siae_full)
     SiaeLabelFactory(siae=siae_full)
     siae_full.save()  # to update stats
     self.assertFalse(siae_full.is_missing_content)
     siae_full_2.sectors.add(sector)
     SiaeOfferFactory(siae=siae_full_2)
     SiaeLabelFactory(siae=siae_full_2)
     siae_full_2.save()  # to update stats
     self.assertFalse(siae_full_2.is_missing_content)
Exemple #2
0
 def test_update_address_coords_field(self):
     siae = SiaeFactory(address="", post_code="", city="", department="", region="")
     self.assertEqual(siae.address, "")
     self.assertEqual(siae.coords, None)
     siae.address = "20 Avenue de Segur"
     siae.city = "Paris"
     siae.save()
     siae = Siae.objects.get(id=siae.id)  # we need to fetch it again to make sure
     self.assertNotEqual(siae.coords, None)
Exemple #3
0
 def test_update_related_count_on_save(self):
     siae = SiaeFactory()
     SiaeOfferFactory(siae=siae)
     self.assertEqual(siae.offers.count(), 1)
     # self.assertEqual(siae.offer_count, 1)  # won't work, need to call save() method to update stat fields
     siae.save()
     self.assertEqual(siae.offer_count, 1)
     self.assertEqual(siae.user_count, 0)
     self.assertEqual(siae.sector_count, 0)
Exemple #4
0
 def test_should_bring_the_siae_with_offers_to_the_top(self):
     siae_with_offer = SiaeFactory(name="ZZ ESI 3")
     SiaeOfferFactory(siae=siae_with_offer)
     siae_with_offer.save()  # to update the siae count fields
     url = reverse("siae:search_results", kwargs={})
     response = self.client.get(url)
     siaes = list(response.context["siaes"])
     self.assertEqual(len(siaes), 3 + 1)
     self.assertEqual(siaes[0].has_offer, True)
     self.assertEqual(siaes[0].name, "ZZ ESI 3")
Exemple #5
0
 def test_update_content_fill_date_on_save(self):
     # siae to update
     siae = SiaeFactory(description="")
     user = UserFactory()
     siae.users.add(user)
     sector = SectorFactory()
     siae.sectors.add(sector)
     self.assertEqual(siae.content_filled_basic_date, None)
     siae.description = "test"
     siae.save()
     self.assertNotEqual(siae.content_filled_basic_date, None)
     # siae should be skipped now
     fill_date = siae.content_filled_basic_date
     siae.description = "another test"
     siae.save()
     self.assertEqual(siae.content_filled_basic_date, fill_date)
Exemple #6
0
 def test_update_last_updated_fields(self):
     siae = SiaeFactory()
     self.assertEqual(siae.employees_insertion_count, None)
     self.assertEqual(siae.employees_insertion_count_last_updated, None)
     # new value: last_updated field will be set
     siae = Siae.objects.get(id=siae.id)  # we need to fetch it again to pass through the __init__
     siae.employees_insertion_count = 10
     siae.save()
     self.assertEqual(siae.employees_insertion_count, 10)
     self.assertNotEqual(siae.employees_insertion_count_last_updated, None)
     employees_insertion_count_last_updated = siae.employees_insertion_count_last_updated
     # same value: last_updated field will not be updated
     siae = Siae.objects.get(id=siae.id)
     siae.employees_insertion_count = 10
     siae.save()
     self.assertEqual(siae.employees_insertion_count, 10)
     self.assertEqual(siae.employees_insertion_count_last_updated, employees_insertion_count_last_updated)
     # updated value: last_updated field will be updated
     siae = Siae.objects.get(id=siae.id)
     siae.employees_insertion_count = 15
     siae.save()
     self.assertEqual(siae.employees_insertion_count, 15)
     self.assertNotEqual(siae.employees_insertion_count_last_updated, employees_insertion_count_last_updated)