From 4c46c30d25e89e90829980355b8ca09856e6cc48 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 15 Nov 2013 13:00:57 +0100 Subject: [PATCH] more api tests (mostly triggering execution of some code) it's hard to test anything without a user / http auth / login / session. --- nsupdate/api/_tests/test_api.py | 18 +++++++++++++++++- nsupdate/main/urls.py | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/nsupdate/api/_tests/test_api.py b/nsupdate/api/_tests/test_api.py index 54cf43b..5160c6f 100644 --- a/nsupdate/api/_tests/test_api.py +++ b/nsupdate/api/_tests/test_api.py @@ -14,5 +14,21 @@ def test_myip(client): def test_nic_update(client): - response = client.get(reverse('update')) + response = client.get(reverse('nic_update')) assert response.status_code == 401 + + +def test_nic_update_session(client): + response = client.get(reverse('nic_update_authorized')) + assert response.status_code == 302 # redirects to login view + + +def test_detect_ip(client): + response = client.get(reverse('detectip', args=('invalid_session_id', ))) + assert response.status_code == 204 + + +def test_ajax_get_ips(client): + response = client.get(reverse('ajax_get_ips')) + assert response.status_code == 200 + diff --git a/nsupdate/main/urls.py b/nsupdate/main/urls.py index 9add347..a821406 100644 --- a/nsupdate/main/urls.py +++ b/nsupdate/main/urls.py @@ -24,12 +24,12 @@ urlpatterns = patterns( url(r'^domain_overview/$', DomainOverwievView.as_view(), name='domain_overview'), url(r'^domain/(?P\d+)/delete/$', DeleteDomainView.as_view(), name='delete_domain'), # internal use by the web ui - url(r'^detectip/(?P\w+)/$', DetectIpView.as_view()), + url(r'^detectip/(?P\w+)/$', DetectIpView.as_view(), name='detectip'), url(r'^ajax_get_ips/$', AjaxGetIps.as_view(), name="ajax_get_ips"), url(r'^nic/update_authorized$', AuthorizedNicUpdateView.as_view(), name='nic_update_authorized'), # api (for update clients) url(r'^myip$', myip_view, name='myip'), - url(r'^nic/update$', NicUpdateView.as_view(), name='update'), + url(r'^nic/update$', NicUpdateView.as_view(), name='nic_update'), # for bots url(r'^robots.txt$', RobotsTxtView.as_view()), )