コード例 #1
0
ファイル: views.py プロジェクト: evanepio/dotman-comics
    def setUp(self):

        one_day = timedelta(days=1)
        today = datetime.now() - timedelta(seconds=1)
        yesterday = today - one_day
        tomorrow = today + one_day

        series = WebComicSeries(name="Chaos Crystal", series_slug="chaoscrystal", start_date=yesterday)
        series.save()

        self.wc_image1 = WebComicImage(page_number=1, release_date=yesterday, series=series)
        self.wc_image1.save()

        self.wc_image2 = WebComicImage(page_number=2, release_date=today, series=series)
        self.wc_image2.save()

        self.wc_image3 = WebComicImage(page_number=3, release_date=tomorrow, series=series)
        self.wc_image3.save()
コード例 #2
0
ファイル: views.py プロジェクト: evanepio/dotman-comics
class WebComicSeriesDetailViewTestCase(TestCase):
    urls = "comics.tests.urls"

    def setUp(self):

        one_day = timedelta(days=1)
        today = datetime.now() - timedelta(seconds=1)
        yesterday = today - one_day
        tomorrow = today + one_day

        series = WebComicSeries(name="Chaos Crystal", series_slug="chaoscrystal", start_date=yesterday)
        series.save()

        self.wc_image1 = WebComicImage(page_number=1, release_date=yesterday, series=series)
        self.wc_image1.save()

        self.wc_image2 = WebComicImage(page_number=2, release_date=today, series=series)
        self.wc_image2.save()

        self.wc_image3 = WebComicImage(page_number=3, release_date=tomorrow, series=series)
        self.wc_image3.save()

    def test_exists(self):
        # test
        response = self.client.get("/webcomics/chaoscrystal/")

        self.assertEqual(response.status_code, 200)

    def test_contains_two_names(self):
        # test
        response = self.client.get("/webcomics/chaoscrystal/")

        self.assertContains(response, "Page 1")
        self.assertContains(response, "Page 2")
        self.assertNotContains(response, "Page 3")

    def test_contains_two_urls(self):
        # test
        response = self.client.get("/webcomics/chaoscrystal/")

        self.assertContains(response, self.wc_image1.get_absolute_url())
        self.assertContains(response, self.wc_image2.get_absolute_url())
        self.assertNotContains(response, self.wc_image3.get_absolute_url())