mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add tests for home and search views
This commit is contained in:
0
netbox/netbox/tests/__init__.py
Normal file
0
netbox/netbox/tests/__init__.py
Normal file
13
netbox/netbox/tests/test_api.py
Normal file
13
netbox/netbox/tests/test_api.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from utilities.testing import APITestCase
|
||||||
|
|
||||||
|
|
||||||
|
class AppTest(APITestCase):
|
||||||
|
|
||||||
|
def test_root(self):
|
||||||
|
|
||||||
|
url = reverse('api-root')
|
||||||
|
response = self.client.get('{}?format=api'.format(url), **self.header)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
24
netbox/netbox/tests/test_views.py
Normal file
24
netbox/netbox/tests/test_views.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
from django.test import TestCase
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
|
class HomeViewTestCase(TestCase):
|
||||||
|
|
||||||
|
def test_home(self):
|
||||||
|
|
||||||
|
url = reverse('home')
|
||||||
|
|
||||||
|
response = self.client.get(url)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_search(self):
|
||||||
|
|
||||||
|
url = reverse('search')
|
||||||
|
params = {
|
||||||
|
'q': 'foo',
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.get('{}?{}'.format(url, urllib.parse.urlencode(params)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
Reference in New Issue
Block a user