Split up tests into own directory and separate files

This commit is contained in:
Jeffrey Forman 2012-12-01 14:41:40 -05:00
parent d5b2197571
commit 02caf7c983
4 changed files with 31 additions and 12 deletions

3
binder/tests/__init__.py Normal file
View File

@ -0,0 +1,3 @@
from models import *
from views import *
from helpers import *

16
binder/tests/helpers.py Normal file
View File

@ -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)

11
binder/tests/models.py Normal file
View File

@ -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)

View File

@ -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, ('<div class="alert alert-error">Errors were encountered: <br>'
@ -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. """