From a5f0a00e79fc5598203e510c1774a1084cfdbf26 Mon Sep 17 00:00:00 2001 From: elnappo Date: Fri, 2 Jan 2015 13:19:51 +0100 Subject: [PATCH 1/3] add some tests --- nsupdate/accounts/_tests/test_accounts.py | 10 ++++++++++ nsupdate/main/_tests/test_main.py | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/nsupdate/accounts/_tests/test_accounts.py b/nsupdate/accounts/_tests/test_accounts.py index 89fbf74..e585bf3 100644 --- a/nsupdate/accounts/_tests/test_accounts.py +++ b/nsupdate/accounts/_tests/test_accounts.py @@ -17,7 +17,12 @@ def test_views_anon(client): for view, kwargs, status_code in [ # stuff that requires being logged-in redirects to the login view: ('account_profile', dict(), 302), + ('account_settings', dict(), 302), ('account_delete', dict(), 302), + ('registration_disallowed', dict(), 200), + ('registration_complete', dict(), 200), + ('registration_register', dict(), 200), + ('registration_activation_complete', dict(), 200), ]: print("%s, %s, %s" % (view, kwargs, status_code)) response = client.get(reverse(view, kwargs=kwargs)) @@ -28,7 +33,12 @@ def test_views_logged_in(client): client.login(username=USERNAME, password=PASSWORD) for view, kwargs, status_code in [ ('account_profile', dict(), 200), + ('account_settings', dict(), 200), ('account_delete', dict(), 200), + ('registration_disallowed', dict(), 200), + ('registration_complete', dict(), 200), + ('registration_register', dict(), 200), + ('registration_activation_complete', dict(), 200), ]: print("%s, %s, %s" % (view, kwargs, status_code)) response = client.get(reverse(view, kwargs=kwargs)) diff --git a/nsupdate/main/_tests/test_main.py b/nsupdate/main/_tests/test_main.py index 27035a4..7cc9265 100644 --- a/nsupdate/main/_tests/test_main.py +++ b/nsupdate/main/_tests/test_main.py @@ -24,14 +24,19 @@ def test_views_anon(client): ('generate_secret_view', dict(pk=1), 302), ('generate_ns_secret_view', dict(pk=1), 302), ('host_view', dict(pk=1), 302), + ('host_view', dict(pk=2), 302), + ('host_view', dict(pk=100), 302), ('add_host', dict(), 302), ('delete_host', dict(pk=1), 302), ('related_host_view', dict(mpk=1, pk=1), 302), ('add_related_host', dict(mpk=1), 302), ('delete_related_host', dict(mpk=1, pk=1), 302), ('domain_view', dict(pk=1), 302), + ('domain_view', dict(pk=2), 302), + ('domain_view', dict(pk=100), 302), ('add_domain', dict(), 302), ('delete_domain', dict(pk=1), 302), + ('delete_domain', dict(pk=2), 302), ('updater_hostconfig_overview', dict(pk=1), 302), ('updater_hostconfig', dict(pk=1), 302), ('delete_updater_hostconfig', dict(pk=1), 302), @@ -52,19 +57,31 @@ def test_views_logged_in(client): ('status', dict(), 200), ('overview', dict(), 200), ('generate_secret_view', dict(pk=1), 200), + ('generate_secret_view', dict(pk=2), 404), + ('generate_secret_view', dict(pk=100), 404), ('generate_ns_secret_view', dict(pk=1), 200), + ('generate_ns_secret_view', dict(pk=2), 404), ('host_view', dict(pk=1), 200), + ('host_view', dict(pk=2), 404), + ('host_view', dict(pk=100), 404), ('add_host', dict(), 200), ('delete_host', dict(pk=1), 200), + ('delete_host', dict(pk=2), 404), ('related_host_view', dict(mpk=1, pk=1), 200), ('add_related_host', dict(mpk=1), 200), ('delete_related_host', dict(mpk=1, pk=1), 200), ('domain_view', dict(pk=1), 200), + ('domain_view', dict(pk=2), 404), + ('domain_view', dict(pk=100), 404), ('add_domain', dict(), 200), ('delete_domain', dict(pk=1), 200), + ('delete_domain', dict(pk=2), 404), ('updater_hostconfig_overview', dict(pk=1), 200), + ('updater_hostconfig_overview', dict(pk=2), 404), ('updater_hostconfig', dict(pk=1), 200), + ('updater_hostconfig', dict(pk=2), 404), ('delete_updater_hostconfig', dict(pk=1), 200), + ('delete_updater_hostconfig', dict(pk=2), 404), ('update', dict(), 401), ]: print("%s, %s, %s" % (view, kwargs, status_code)) From 2963e60aa215710163aa6ed79356c71038565eeb Mon Sep 17 00:00:00 2001 From: elnappo Date: Fri, 2 Jan 2015 14:18:49 +0100 Subject: [PATCH 2/3] add more test for main views (mostly 404) --- conftest.py | 3 ++- nsupdate/main/_tests/test_main.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 995a32c..d7fe168 100644 --- a/conftest.py +++ b/conftest.py @@ -122,7 +122,8 @@ def db_init(db): # note: db is a predefined fixture and required here to have t RelatedHost.objects.create(name=RELATED_HOST_NAME, interface_id_ipv4="0.0.0.1", interface_id_ipv6="::1", main_host=h) - + RelatedHost.objects.create(name=RELATED_HOST_NAME, + interface_id_ipv4="0.0.0.1", interface_id_ipv6="::1", main_host=h2) def pytest_runtest_setup(item): activate('en') diff --git a/nsupdate/main/_tests/test_main.py b/nsupdate/main/_tests/test_main.py index 7cc9265..2fa14b6 100644 --- a/nsupdate/main/_tests/test_main.py +++ b/nsupdate/main/_tests/test_main.py @@ -28,8 +28,11 @@ def test_views_anon(client): ('host_view', dict(pk=100), 302), ('add_host', dict(), 302), ('delete_host', dict(pk=1), 302), + ('related_host_overview', dict(), 302), ('related_host_view', dict(mpk=1, pk=1), 302), ('add_related_host', dict(mpk=1), 302), + ('add_related_host', dict(mpk=2), 302), + ('add_related_host', dict(mpk=100), 302), ('delete_related_host', dict(mpk=1, pk=1), 302), ('domain_view', dict(pk=1), 302), ('domain_view', dict(pk=2), 302), @@ -61,27 +64,44 @@ def test_views_logged_in(client): ('generate_secret_view', dict(pk=100), 404), ('generate_ns_secret_view', dict(pk=1), 200), ('generate_ns_secret_view', dict(pk=2), 404), + ('generate_ns_secret_view', dict(pk=100), 404), ('host_view', dict(pk=1), 200), ('host_view', dict(pk=2), 404), ('host_view', dict(pk=100), 404), ('add_host', dict(), 200), ('delete_host', dict(pk=1), 200), ('delete_host', dict(pk=2), 404), + ('delete_host', dict(pk=100), 404), + ('related_host_overview', dict(), 200), ('related_host_view', dict(mpk=1, pk=1), 200), + ('related_host_view', dict(mpk=2, pk=1), 404), + ('related_host_view', dict(mpk=100, pk=1), 404), + ('related_host_view', dict(mpk=1, pk=2), 404), + ('related_host_view', dict(mpk=1, pk=100), 404), ('add_related_host', dict(mpk=1), 200), + ('add_related_host', dict(mpk=2), 404), + ('add_related_host', dict(mpk=100), 404), ('delete_related_host', dict(mpk=1, pk=1), 200), + ('delete_related_host', dict(mpk=2, pk=1), 404), + ('delete_related_host', dict(mpk=100, pk=1), 404), + ('delete_related_host', dict(mpk=1, pk=2), 404), + ('delete_related_host', dict(mpk=1, pk=100), 404), ('domain_view', dict(pk=1), 200), ('domain_view', dict(pk=2), 404), ('domain_view', dict(pk=100), 404), ('add_domain', dict(), 200), ('delete_domain', dict(pk=1), 200), ('delete_domain', dict(pk=2), 404), + ('delete_domain', dict(pk=100), 404), ('updater_hostconfig_overview', dict(pk=1), 200), ('updater_hostconfig_overview', dict(pk=2), 404), + ('updater_hostconfig_overview', dict(pk=100), 404), ('updater_hostconfig', dict(pk=1), 200), ('updater_hostconfig', dict(pk=2), 404), + ('updater_hostconfig', dict(pk=100), 404), ('delete_updater_hostconfig', dict(pk=1), 200), ('delete_updater_hostconfig', dict(pk=2), 404), + ('delete_updater_hostconfig', dict(pk=100), 404), ('update', dict(), 401), ]: print("%s, %s, %s" % (view, kwargs, status_code)) From a0c0ba467ce3eca24d9f09ed9b2963f45899a2a6 Mon Sep 17 00:00:00 2001 From: elnappo Date: Fri, 2 Jan 2015 14:25:06 +0100 Subject: [PATCH 3/3] fixed missing url parm for related_host_overview --- nsupdate/main/_tests/test_main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nsupdate/main/_tests/test_main.py b/nsupdate/main/_tests/test_main.py index 2fa14b6..d887104 100644 --- a/nsupdate/main/_tests/test_main.py +++ b/nsupdate/main/_tests/test_main.py @@ -28,7 +28,8 @@ def test_views_anon(client): ('host_view', dict(pk=100), 302), ('add_host', dict(), 302), ('delete_host', dict(pk=1), 302), - ('related_host_overview', dict(), 302), + ('related_host_overview', dict(mpk=1), 302), + ('related_host_overview', dict(mpk=100), 302), ('related_host_view', dict(mpk=1, pk=1), 302), ('add_related_host', dict(mpk=1), 302), ('add_related_host', dict(mpk=2), 302), @@ -72,7 +73,9 @@ def test_views_logged_in(client): ('delete_host', dict(pk=1), 200), ('delete_host', dict(pk=2), 404), ('delete_host', dict(pk=100), 404), - ('related_host_overview', dict(), 200), + ('related_host_overview', dict(mpk=1), 200), + ('related_host_overview', dict(mpk=2), 404), + ('related_host_overview', dict(mpk=100), 404), ('related_host_view', dict(mpk=1, pk=1), 200), ('related_host_view', dict(mpk=2, pk=1), 404), ('related_host_view', dict(mpk=100, pk=1), 404),