From 02caf7c983644dddb2c08d2c58ebc8ba006beb0f Mon Sep 17 00:00:00 2001 From: Jeffrey Forman Date: Sat, 1 Dec 2012 14:41:40 -0500 Subject: [PATCH] Split up tests into own directory and separate files --- binder/tests/__init__.py | 3 +++ binder/tests/helpers.py | 16 ++++++++++++++++ binder/tests/models.py | 11 +++++++++++ binder/{tests.py => tests/views.py} | 13 +------------ 4 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 binder/tests/__init__.py create mode 100644 binder/tests/helpers.py create mode 100644 binder/tests/models.py rename binder/{tests.py => tests/views.py} (89%) 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. """