Esempio n. 1
0
    def test_never_return_non_existing_link(self):
        non_existing = models.Surprise.objects.create(
            link="http://hjdsfhsdhfjdshfsdj.com",
            link_exists=False,
        )
        existing = models.Surprise.objects.create(
            link="http://fjhdsfhjdskhfjs.com",
            link_exists=True,
        )

        random_surprises = [models.get_random_surprise() for _ in range(100)]

        self.assertIn(existing, random_surprises)
        self.assertNotIn(non_existing, random_surprises)
Esempio n. 2
0
 def get_redirect_url(self, *args, **kwargs):
     surprise = models.get_random_surprise()
     return reverse("surprise-detail", kwargs=dict(pk=surprise.id))