diff options
author | Sanyam Khurana <sanyam.khurana01@gmail.com> | 2019-01-10 15:30:00 +0530 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2019-01-11 10:32:22 -0500 |
commit | 76d31be2d04dd6e6bcb5cb39a29ea9ed3938d0f9 (patch) | |
tree | 696b5d2c59b40be4d9f4072967650bb33ed725ff /tests/sitemaps_tests | |
parent | 6d73278d38e65b5785ce67f21c7ef6d7082aec0a (diff) | |
download | django-76d31be2d04dd6e6bcb5cb39a29ea9ed3938d0f9.tar.gz |
Refs #23829 -- Made ping_google command/function use https for the sitemap URL.
Diffstat (limited to 'tests/sitemaps_tests')
-rw-r--r-- | tests/sitemaps_tests/test_management.py | 8 | ||||
-rw-r--r-- | tests/sitemaps_tests/test_utils.py | 14 |
2 files changed, 14 insertions, 8 deletions
diff --git a/tests/sitemaps_tests/test_management.py b/tests/sitemaps_tests/test_management.py index f0be10224b..f91de8ac4b 100644 --- a/tests/sitemaps_tests/test_management.py +++ b/tests/sitemaps_tests/test_management.py @@ -10,8 +10,8 @@ class PingGoogleTests(SitemapTestsBase): def test_default(self, ping_google_func): call_command('ping_google') - ping_google_func.assert_called_with(sitemap_url=None) + ping_google_func.assert_called_with(sitemap_url=None, sitemap_uses_https=True) - def test_arg(self, ping_google_func): - call_command('ping_google', 'foo.xml') - ping_google_func.assert_called_with(sitemap_url='foo.xml') + def test_args(self, ping_google_func): + call_command('ping_google', 'foo.xml', '--sitemap-uses-http') + ping_google_func.assert_called_with(sitemap_url='foo.xml', sitemap_uses_https=False) diff --git a/tests/sitemaps_tests/test_utils.py b/tests/sitemaps_tests/test_utils.py index 158f1625ce..34f46c45b3 100644 --- a/tests/sitemaps_tests/test_utils.py +++ b/tests/sitemaps_tests/test_utils.py @@ -15,16 +15,16 @@ class PingGoogleTests(SitemapTestsBase): @mock.patch('django.contrib.sitemaps.urlopen') def test_something(self, urlopen): ping_google() - params = urlencode({'sitemap': 'http://example.com/sitemap-without-entries/sitemap.xml'}) + params = urlencode({'sitemap': 'https://example.com/sitemap-without-entries/sitemap.xml'}) full_url = 'https://www.google.com/webmasters/tools/ping?%s' % params urlopen.assert_called_with(full_url) def test_get_sitemap_full_url_global(self): - self.assertEqual(_get_sitemap_full_url(None), 'http://example.com/sitemap-without-entries/sitemap.xml') + self.assertEqual(_get_sitemap_full_url(None), 'https://example.com/sitemap-without-entries/sitemap.xml') @override_settings(ROOT_URLCONF='sitemaps_tests.urls.index_only') def test_get_sitemap_full_url_index(self): - self.assertEqual(_get_sitemap_full_url(None), 'http://example.com/simple/index.xml') + self.assertEqual(_get_sitemap_full_url(None), 'https://example.com/simple/index.xml') @override_settings(ROOT_URLCONF='sitemaps_tests.urls.empty') def test_get_sitemap_full_url_not_detected(self): @@ -33,7 +33,13 @@ class PingGoogleTests(SitemapTestsBase): _get_sitemap_full_url(None) def test_get_sitemap_full_url_exact_url(self): - self.assertEqual(_get_sitemap_full_url('/foo.xml'), 'http://example.com/foo.xml') + self.assertEqual(_get_sitemap_full_url('/foo.xml'), 'https://example.com/foo.xml') + + def test_get_sitemap_full_url_insecure(self): + self.assertEqual( + _get_sitemap_full_url('/foo.xml', sitemap_uses_https=False), + 'http://example.com/foo.xml' + ) @modify_settings(INSTALLED_APPS={'remove': 'django.contrib.sites'}) def test_get_sitemap_full_url_no_sites(self): |