Changeset 6350


Ignore:
Timestamp:
Oct 28, 2008, 9:40:05 PM (16 years ago)
Author:
roland
Message:

Worked on unittests for wllogic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/tests.py

    r6340 r6350  
    11import unittest
    22from django.test.client import Client
     3from django.db import connection
     4
     5from exodus import settings
    36
    47class AddTest(unittest.TestCase):
     
    69        #Set up the client
    710        self.client = Client()
     11       
     12        #Set up the database
     13        self.olddbname = settings.DATABASE_NAME
     14        self.dbname = connection.creation.create_test_db()
     15
     16    def tearDown(self):
     17        connection.creation.destroy_test_db(self.olddbname)
    818
    919    def test_addlocation(self):
    10         # Issue a post.
    11         response = self.client.post('/location/add/new/', \
    12             {'description': 'JohnLaan', 'Longitude': '34.55', \
    13             'Latitude' : '44.55', 'proceed': 'OK, proceed'})
     20        post_data = {'description': 'JohnLaan2', 'Longitude': '34.55', \
     21            'Latitude' : '44.55', 'pro/ceed': 'OK, proceed'}
     22        response = self.client.post('/add/Location/new/', post_data)
    1423
    15         # Check if response add location is 200.
    1624        self.failUnlessEqual(response.status_code, 200)
    1725
    1826    def test_addnode(self):
    19         # Issue a post.
    20         response = self.client.post('/node/add/new/', \
    21             {'name' : 'Tabitha', 'location' : 1, \
    22             'status' : 'up', 'network' : 1, 'proceed': 'OK, proceed'})
     27        post_data = {'name' : 'Tabitha', 'location' : 1, \
     28            'status' : 'up', 'network' : 1, 'proceed': 'OK, proceed'}
    2329
    24         # Check if response add location is 200.
     30        response = self.client.post('/add/node/new/', post_data)
     31
    2532        self.failUnlessEqual(response.status_code,200)
    26            
    2733
     34class wllogic(unittest.TestCase):
     35    def test_new_SSID_name(self):
     36        node = {}
     37        node['name'] = 'testnode'
     38        #XXX figure out node.name = 'testnode' and node.network.name='iets'
     39
     40    def test_parse_addr(self):
     41        ip = '192.168.3.4'
     42        from exodus.wllogic import parseaddr
     43        parsed = parseaddr(ip)
     44        from exodus.wllogic import showaddr
     45        o_ip = showaddr(parsed)
     46        self.failUnlessEqual(o_ip, ip)
     47         
    2848def suite():
    29     return unittest.makeSuite(AddTest)
     49    s = unittest.TestSuite()
     50    s.addTest(unittest.makeSuite(AddTest))
     51    s.addTest(unittest.makeSuite(wllogic))
     52
     53    return s
Note: See TracChangeset for help on using the changeset viewer.