diff --git a/binder/tests/__init__.py b/binder/tests/__init__.py new file mode 100644 index 0000000..758429c --- /dev/null +++ b/binder/tests/__init__.py @@ -0,0 +1,3 @@ +from models import * +from views import * +from helpers import * diff --git a/binder/tests/helpers.py b/binder/tests/helpers.py new file mode 100644 index 0000000..d96d9c7 --- /dev/null +++ b/binder/tests/helpers.py @@ -0,0 +1,16 @@ +from django.test import TestCase + +from binder import models, helpers + +class HelperTests(TestCase): + def test_ipinfo_ResolutionFail(self): + response = helpers.ip_info("foobar.doesnotexist.local") + self.assertEqual([['Error', u'Unable to resolve foobar.doesnotexist.local: [Errno -2] Name or service not known']], + response) + # The following is currently the first globally unique IPv4 and IPv6 address I could find + # that did not change based upon your geography. + # http://test-ipv6.com/ + response = helpers.ip_info("ds.test-ipv6.com") + self.assertEqual([['IPv4 (1)', u'216.218.228.114'], ['IPv6 (1)', u'2001:470:1:18::2']], + response) + diff --git a/binder/tests/models.py b/binder/tests/models.py new file mode 100644 index 0000000..a4f83ae --- /dev/null +++ b/binder/tests/models.py @@ -0,0 +1,11 @@ +from django.test import TestCase + +from binder import models + +class ModelTests(TestCase): + def test_EmptyBindServerModel(self): + self.assertEqual(models.BindServer.objects.count(), 0) + bindserver_1 = models.BindServer(hostname="test1", + statistics_port = 1234) + bindserver_1.save() + self.assertEqual(models.BindServer.objects.count(), 1) diff --git a/binder/tests.py b/binder/tests/views.py similarity index 89% rename from binder/tests.py rename to binder/tests/views.py index 48619f8..9e612a3 100644 --- a/binder/tests.py +++ b/binder/tests/views.py @@ -2,7 +2,6 @@ from django.test import TestCase from django.test.client import Client from binder import models, helpers -from collections import OrderedDict class GetTests(TestCase): @@ -31,9 +30,7 @@ class GetTests(TestCase): self.assertEqual(response.status_code, 200) def test_GetInvalidServer(self): - """ Attempt to get a zone list for a server - not configured in the database. - """ + """ Attempt to get a zone list for a server not in the database.""" response = self.client.get("/info/unconfigured.server.net/") self.assertEqual(response.status_code, 200) self.assertContains(response, ('
Errors were encountered:
' @@ -41,14 +38,6 @@ class GetTests(TestCase): html=True) -class ModelTests(TestCase): - def test_EmptyBindServerModel(self): - self.assertEqual(models.BindServer.objects.count(), 0) - bindserver_1 = models.BindServer(hostname="test1", - statistics_port = 1234) - bindserver_1.save() - self.assertEqual(models.BindServer.objects.count(), 1) - class PostTests(TestCase): """ Unit Tests that exercise HTTP POST. """