예제 #1
0
    def setUp(self):
        """Create Wagtail pages used in tests."""
        # The site needs a Conference to work properly.
        self.conference = Conference(title="Conference")
        self.conference.save()

        homepage = HomePage(title="Home",
                            path="0002",
                            depth=1,
                            ticketing_url=self.EXAMPLE_URL)
        homepage.save()
        # We need to replace the "Welcome to Wagtail" page with this page.
        site = Site.objects.get()
        site.root_page = homepage
        site.save()

        other_page = HTMLPage(title="Other", path="0003")
        homepage.add_child(instance=other_page)
        other_page.save()
예제 #2
0
 def setUp(self):
     # Create base conference infrastructure that has to exist in
     # order to create a Proposal.
     conference = Conference(title="Conference")
     conference.save()
     section = Section(conference=conference,
                       name="Section",
                       slug="section")
     section.save()
     proposal_kind = ProposalKind(section=section, name="Kind", slug="kind")
     proposal_kind.save()
     speaker = Speaker(name="Paul Ryan")
     speaker.save()
     self.proposal = Proposal.objects.create(
         title="Title",
         description="Description",
         abstract="Abstract",
         kind=proposal_kind,
         speaker=speaker,
         audience_level=1,
     )
예제 #3
0
class HomePageContextTestCase(TestCase):
    EXAMPLE_URL = "http://example.com"

    @classmethod
    def setUp(self):
        """Create Wagtail pages used in tests."""
        # The site needs a Conference to work properly.
        self.conference = Conference(title="Conference")
        self.conference.save()

        homepage = HomePage(title="Home",
                            path="0002",
                            depth=1,
                            ticketing_url=self.EXAMPLE_URL)
        homepage.save()
        # We need to replace the "Welcome to Wagtail" page with this page.
        site = Site.objects.get()
        site.root_page = homepage
        site.save()

        other_page = HTMLPage(title="Other", path="0003")
        homepage.add_child(instance=other_page)
        other_page.save()

    def test_homepage_context(self):
        homepage = HomePage.objects.get()
        with self.settings(CONFERENCE_ID=self.conference.id):
            response = self.client.get(homepage.url)
        self.assertEqual(response.context["ticketing_url"], self.EXAMPLE_URL)

    def test_other_wagtail_page_context(self):
        other_page = HTMLPage.objects.get()
        response = self.client.get(other_page.url)
        self.assertEqual(response.context["ticketing_url"], self.EXAMPLE_URL)

    def test_symposion_page_context(self):
        response = self.client.get(reverse("account_login"))
        self.assertEqual(response.context["ticketing_url"], self.EXAMPLE_URL)
    def setUp(self):
        self.speaker = Speaker.objects.create(name="Paul Ryan")
        self.speaker_profile_url = reverse(
            "speaker_profile",
            kwargs={"pk": self.speaker.pk, "slug": self.speaker.slug},
        )
        # Create base conference infrastructure.
        conference = Conference(title="Conference")
        conference.save()
        section = Section(
            conference=conference, name="Section", slug="section"
        )
        section.save()
        proposal_kind = ProposalKind(section=section, name="Kind", slug="kind")
        proposal_kind.save()
        first_proposal_base = ProposalBase.objects.create(
            title=FIRST_PRESENTATION_TITLE,
            description="Description",
            abstract="Abstract",
            kind=proposal_kind,
            speaker=self.speaker,
        )
        second_proposal_base = ProposalBase.objects.create(
            title=SECOND_PRESENTATION_TITLE,
            description="Description",
            abstract="Abstract",
            kind=proposal_kind,
            speaker=self.speaker,
        )

        # Note that saving ProposalResults will automatically
        # create or delete presentations. However, we want to test whether
        # presentations appear on speaker profile pages,
        # not whether ProposalResults create Presentations successfully.

        schedule = Schedule.objects.create(section=section)
        day = Day.objects.create(schedule=schedule, date=timezone.now().date())
        kind = SlotKind.objects.create(schedule=schedule, label="45-min talk")

        self.first_presentation = Presentation.objects.create(
            slot=Slot.objects.create(
                day=day, kind=kind, start=timezone.now(), end=timezone.now()
            ),
            title=FIRST_PRESENTATION_TITLE,
            description="Description",
            abstract="Abstract",
            speaker=self.speaker,
            proposal_base=first_proposal_base,
            section=section,
        )
        self.second_presentation = Presentation.objects.create(
            slot=Slot.objects.create(
                day=day, kind=kind, start=timezone.now(), end=timezone.now()
            ),
            title=SECOND_PRESENTATION_TITLE,
            description="Description",
            abstract="Abstract",
            speaker=self.speaker,
            proposal_base=second_proposal_base,
            section=section,
        )
예제 #5
0
class HomePageContextTestCase(TestCase):
    EXAMPLE_URL = "http://example.com"

    @classmethod
    def setUp(self):
        """Create Wagtail pages used in tests."""
        # The site needs a Conference to work properly.
        self.conference = Conference(title="Conference")
        self.conference.save()

        homepage = HomePage(title="Home",
                            path="0002",
                            depth=1,
                            ticketing_url=self.EXAMPLE_URL)
        homepage.save()
        # We need to replace the "Welcome to Wagtail" page with this page.
        site = Site.objects.get()
        site.root_page = homepage
        site.save()

        other_page = HTMLPage(title="Other",
                              path="0003")
        homepage.add_child(instance=other_page)
        other_page.save()

    def test_homepage_context(self):
        homepage = HomePage.objects.get()
        with self.settings(CONFERENCE_ID=self.conference.id):
            response = self.client.get(homepage.url)
        self.assertEqual(response.context["ticketing_url"], self.EXAMPLE_URL)

    def test_other_wagtail_page_context(self):
        other_page = HTMLPage.objects.get()
        response = self.client.get(other_page.url)
        self.assertEqual(response.context["ticketing_url"], self.EXAMPLE_URL)

    def test_symposion_page_context(self):
        response = self.client.get(reverse("account_login"))
        self.assertEqual(response.context["ticketing_url"], self.EXAMPLE_URL)

    @override_settings(
        STATICFILES_STORAGE=(
            "django.contrib.staticfiles.storage.StaticFilesStorage"
        )
    )
    def test_logo_image(self):
        homepage = HomePage.objects.get()
        self.assertIsNone(homepage.logo_image)
        with self.settings(CONFERENCE_ID=self.conference.id):
            # Test that default logo image appears.
            response = self.client.get(homepage.url)
            self.assertContains(response, "/logo.png")
            # Replace default logo with a new image.
            test_logo_name = Faker().uuid4()
            image_file = ImageFile(
                open("conf_site/cms/tests/test-logo.png", "rb"), test_logo_name
            )
            ImageModel = get_image_model()
            image = ImageModel(file=image_file)
            # The image must be saved before it is attached
            # to the homepage.
            image.save()
            homepage.logo_image = image
            homepage.save()
            response = self.client.get(homepage.url)
            self.assertNotContains(response, "/logo.288981a8dfa8.png")
            self.assertContains(response, test_logo_name)