Changeset 6605 for trunk


Ignore:
Timestamp:
Jan 15, 2009, 8:53:37 PM (16 years ago)
Author:
roland
Message:

Working on better tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/tests.py

    r6475 r6605  
    11import unittest
    22
    3 class AddTest(unittest.TestCase):
     3class ExodusTestCase(unittest.TestCase):
    44    def setUp(self):
    5         #Set up the client
    65        from django.test.client import Client
    7         self.client = Client()
    8        
    9         #Set up a inmemory database
     6        self.client = Client()       
    107        from exodus import settings
    118        self.olddbname = settings.DATABASE_NAME
    129        from django.db import connection
    1310        self.dbname = connection.creation.create_test_db(0)
    14        
     11
     12        #create four locations
    1513        from exodus.models import Location
    16 
    17         self.location = Location(description = 'Hooigracht', \
    18             longitude = '45.675433', latitude = '56.543332')
    19         self.location.save()
     14        loc1 = Location.objects.create(description = 'ASW',
     15                latitude = '15.12345',
     16                longitude = '16.12345')
     17        loc2 = Location.objects.create(description = 'Rapenburg',
     18                latitude = '27.12345',
     19                longitude = '28.12345')
     20        loc3 = Location.objects.create(description = 'Lepelenburg',
     21                latitude = '37.12345',
     22                longitude = '48.12345')
     23        loc4 = Location.objects.create(description = 'Neude',
     24                latitude = '57.12345',
     25                longitude = '58.12345')
     26        import pdb; pdb.set_trace() ;
    2027
    2128    def tearDown(self):
     
    2330        connection.creation.destroy_test_db(self.olddbname, 0)
    2431
    25 
    26 class IPCalcTest(unittest.TestCase):
    27     def setUp(self):
    28         #Set up the client
    29         from django.test.client import Client
    30         self.client = Client()
    31        
    32         #Set up a inmemory database
    33         from exodus import settings
    34         self.olddbname = settings.DATABASE_NAME
    35         from django.db import connection
    36         self.dbname = connection.creation.create_test_db(0)
    37    
     32class LocationTest(ExodusTestCase):
     33    pass
     34
     35
     36class IPCalcTest(ExodusTestCase):
     37
     38    def ipcalc(a):
    3839        from exodus.models import Node 
    39         self.node = Node.objects.get(pk=1)
    40        
     40        node = Node.objects.get(pk=1)
    4141        from exodus.wlipcalc import IPCalc
    42         self.ipcalc = lambda a: IPCalc(self.node, a)
    43         self.IPCalc = IPCalc
     42        return IPCalc(node, a)
    4443
    4544    def test_ipcalc_ip_size(self):
     
    108107        self.failUnlessEqual(ipcalc.ips, ip_list)
    109108
    110     def tearDown(self):
    111         from django.db import connection
    112         connection.creation.destroy_test_db(self.olddbname, 0)
    113    
    114 
    115 
    116 class wllogic(unittest.TestCase):
    117     def setUp(self):
    118         #Set up the client
    119         from django.test.client import Client
    120         self.client = Client()
    121        
    122         #Set up the database
    123         from django.db import connection
    124         from exodus import settings
    125         self.olddbname = settings.DATABASE_NAME
    126         self.dbname = connection.creation.create_test_db(0)
    127 
    128     def tearDown(self):
    129         from django.db import connection
    130         connection.creation.destroy_test_db(self.olddbname, 0)
     109class wllogic(ExodusTestCase):
    131110
    132111    def test_new_ssid(self):
     
    303282def suite():
    304283    s = unittest.TestSuite()
    305     s.addTest(unittest.makeSuite(AddTest))
    306284    s.addTest(unittest.makeSuite(wllogic))
    307285    s.addTest(unittest.makeSuite(IPCalcTest))
Note: See TracChangeset for help on using the changeset viewer.