|
7 | 7 | from django.test import TestCase |
8 | 8 | from django.urls import reverse |
9 | 9 |
|
10 | | -from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context |
11 | | - |
12 | 10 |
|
13 | 11 | class MarketingSiteViewTests(TestCase): |
14 | 12 | """ Tests for the marketing site views """ |
15 | 13 |
|
16 | | - def _test_view(self, view_name, mimetype): |
17 | | - """ |
18 | | - Gets a view and tests that it exists. |
19 | | - """ |
20 | | - resp = self.client.get(reverse(view_name)) |
21 | | - assert resp.status_code == 200 |
22 | | - assert resp['Content-Type'] == mimetype |
23 | | - |
24 | | - def test_sitemap(self): |
25 | | - """ |
26 | | - Test the sitemap view |
27 | | - """ |
28 | | - self._test_view('sitemap_xml', 'application/xml') |
29 | | - |
30 | | - def test_about(self): |
31 | | - """ |
32 | | - Test the about view |
33 | | - """ |
34 | | - self._test_view('about', 'text/html') |
35 | | - |
36 | | - def test_about_with_site_configuration(self): |
37 | | - """ |
38 | | - Test the about view with the header and content set in SiteConfiguration. |
39 | | - """ |
40 | | - test_header = "Very Unique Test Header" |
41 | | - test_content = "Very Unique Test Content" |
42 | | - test_header_key = 'static_template_about_header' |
43 | | - test_content_key = 'static_template_about_content' |
44 | | - response = None |
45 | | - configuration = {test_header_key: test_header, test_content_key: test_content} |
46 | | - with with_site_configuration_context(configuration=configuration): |
47 | | - response = self.client.get(reverse("about")) |
48 | | - self.assertContains(response, test_header) |
49 | | - self.assertContains(response, test_content) |
50 | | - |
51 | | - def test_about_with_site_configuration_and_html(self): |
52 | | - """ |
53 | | - Test the about view with html in the header. |
54 | | - """ |
55 | | - test_header = "<i>Very Unique Test Header</i>" |
56 | | - test_content = "<i>Very Unique Test Content</i>" |
57 | | - test_header_key = 'static_template_about_header' |
58 | | - test_content_key = 'static_template_about_content' |
59 | | - response = None |
60 | | - configuration = {test_header_key: test_header, test_content_key: test_content} |
61 | | - with with_site_configuration_context(configuration=configuration): |
62 | | - response = self.client.get(reverse("about")) |
63 | | - self.assertContains(response, test_header) |
64 | | - self.assertContains(response, test_content) |
65 | | - |
66 | 14 | def test_404(self): |
67 | 15 | """ |
68 | 16 | Test the 404 view. |
|
0 commit comments