Exemplo n.º 1
0
    def test_get_context_all_fields(self):
        page = JobListingPage(offices=[self.new_york],
                              regions=[self.northeast],
                              grades=[self.grade])

        context = page.get_context(self.request)

        self.assertEqual(context['offices'], [
            {
                'name': 'New York',
                'state_id': 'NY',
            },
        ])

        self.assertEqual(context['regions'], [
            {
                'name': 'Northeast region',
                'states': ['NY'],
                'major_cities': [
                    {
                        'name': 'Albany',
                        'state_id': 'NY',
                    },
                ],
            },
        ])

        self.assertEqual(context['grades'], ['53'])
Exemplo n.º 2
0
    def test_get_context_with_about_us_snippet(self):
        about_us = ReusableText.objects.create(
            title='About us (For consumers)')

        page = JobListingPage()
        context = page.get_context(self.request)

        self.assertEqual(context['about_us'], about_us)
Exemplo n.º 3
0
    def test_get_context_empty_page(self):
        page = JobListingPage()
        context = page.get_context(self.request)

        self.assertEqual(context['offices'], [])
        self.assertEqual(context['regions'], [])
        self.assertEqual(context['grades'], [])

        self.assertNotIn('about_us', context)