"""Tests for the url module."""fromdjango.contribimportadminfromdjango.urlsimportresolve,reversefromhome.viewsimportIndexViewfrompki.views.issuing_casimportCrlDownloadView
[docs]classTestUrls:"""Test cases for the main `urls.py` of the project."""
[docs]deftest_admin_url_resolves(self,settings):"""Test that the admin panel URL resolves correctly to the admin site."""ifsettings.DEBUG:url=reverse('admin:index')resolver=resolve(url)assertresolver.func==admin.site.index
[docs]deftest_users_url_included(self):"""Test that the 'users/' URL pattern is included and resolves to the correct namespace."""url=reverse('users:login')assertresolve(url).namespace=='users'
[docs]deftest_home_index_url_resolves(self):"""Test that the home index URL resolves to the correct view."""url=reverse('home:index')resolver=resolve(url)assertresolver.func.view_class==IndexView
[docs]deftest_crl_download_url_resolves(self):"""Test that the CRL download URL pattern resolves to `CrlDownloadView`."""url=reverse('crl-download',kwargs={'pk':1})resolver=resolve(url)assertresolver.func.view_class==CrlDownloadView
[docs]deftest_setup_wizard_url_included(self):"""Test that the 'setup-wizard/' URL pattern is included and resolves correctly."""url=reverse('setup_wizard:initial')assertresolve(url).namespace=='setup_wizard'
[docs]deftest_devices_url_included(self):"""Test that the 'devices/' URL pattern is included and resolves correctly."""url=reverse('devices:devices')assertresolve(url).namespace=='devices'
[docs]deftest_est_url_included(self):"""Test that the 'est/' URL pattern is included and resolves correctly."""url=reverse('est:ca-certs-post',kwargs={'domain':'test-domain','certtemplate':'template'})assertresolve(url).namespace=='est'
[docs]deftest_cmp_url_included(self):"""Test that the 'cmp/' URL pattern is included and resolves to the correct namespace."""url=reverse('cmp:initialization',kwargs={'domain':'test-domain'})assertresolve(url).namespace=='cmp'
[docs]deftest_jsi18n_url_resolves(self):"""Test that the JavaScript Catalog (jsi18n) URL resolves correctly."""url=reverse('javascript-catalog')resolver=resolve(url)assertresolver.func.view_class.__name__=='JavaScriptCatalog'