- Timestamp:
- Nov 3, 2008, 1:36:43 PM (16 years ago)
- Location:
- trunk/exodus
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exodus/tests.py
r6357 r6359 1 1 import unittest 2 from django.test.client import Client3 from django.db import connection4 5 from exodus import settings6 2 7 3 class AddTest(unittest.TestCase): 8 4 def setUp(self): 9 5 #Set up the client 6 from django.test.client import Client 10 7 self.client = Client() 11 8 12 9 #Set up the database 10 from exodus import settings 11 self.olddbname = settings.DATABASE_NAME 12 from django.db import connection 13 self.dbname = connection.creation.create_test_db(0) 14 15 from exodus.models import Location 16 17 self.location = Location(description = 'Hooigracht', \ 18 longitude = '45.675433', latitude = '56.543332') 19 self.location.save() 20 21 def tearDown(self): 22 from django.db import connection 23 connection.creation.destroy_test_db(self.olddbname, 0) 24 25 def test_addlocation(self): 26 post_data = {'description': 'JohnLaan2', 'longitude': '34.55', \ 27 'latitude' : '44.55', 'proceed': 'OK, proceed'} 28 response = self.client.post('/add/location/new/', post_data) 29 30 self.failUnlessEqual(response.status_code, 302) 31 self.failUnlessEqual(response['Location'], \ 32 'http://testserver/add/node/new/?location=2') 33 34 from exodus.models import Location 35 36 try: 37 l = Location.objects.get(description = 'JohnLaan2') 38 except Location.DoesNotExist: 39 self.fail("Location wasn't get added.") 40 self.failUnless(str(l.longitude), '34.55') 41 self.failUnless(str(l.latitude), '44.55') 42 43 def test_addnode(self): 44 post_data = {'name' : 'Tabitha', 'location' : 1, \ 45 'status' : 'up', 'network' : 1, 'proceed': 'OK, proceed'} 46 response = self.client.post('/add/node/new/', post_data) 47 48 self.failUnlessEqual(response.status_code, 302) 49 self.failUnlessEqual(response['Location'], \ 50 'http://testserver/view/node/Tabitha/') 51 52 from exodus.models import Node 53 54 try: 55 n = Node.objects.get(name = 'Tabitha') 56 except Node.DoesNotExist: 57 self.fail("Node wasn't added.") 58 59 node = n 60 self.failUnlessEqual(n.location.id, 1) 61 self.failUnlessEqual(n.status, 'up') 62 self.failUnlessEqual(n.network.id, 1) 63 64 c = {} 65 66 for i in n.as_list(): 67 c[i[0]] = i[1] 68 69 self.failUnless(c.has_key('masterip')) 70 71 class wllogic(unittest.TestCase): 72 def setUp(self): 73 #Set up the client 74 from django.test.client import Client 75 self.client = Client() 76 77 #Set up the database 78 from django.db import connection 79 from exodus import settings 13 80 self.olddbname = settings.DATABASE_NAME 14 81 self.dbname = connection.creation.create_test_db(0) 15 82 16 83 def tearDown(self): 17 connection.creation.destroy_test_db(self.olddbname, 0) 18 19 def test_addlocation(self): 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) 23 24 self.failUnlessEqual(response.status_code, 200) 25 26 def test_addnode(self): 27 post_data = {'name' : 'Tabitha', 'location' : 1, \ 28 'status' : 'up', 'network' : 1, 'proceed': 'OK, proceed'} 29 30 response = self.client.post('/add/node/new/', post_data) 31 32 self.failUnlessEqual(response.status_code,200) 33 34 class wllogic(unittest.TestCase): 35 def setUp(self): 36 #Set up the client 37 self.client = Client() 38 39 #Set up the database 40 self.olddbname = settings.DATABASE_NAME 41 self.dbname = connection.creation.create_test_db(0) 42 43 def tearDown(self): 84 from django.db import connection 44 85 connection.creation.destroy_test_db(self.olddbname, 0) 45 86 -
trunk/exodus/views.py
r6357 r6359 245 245 # input a valid master ip into new_data 246 246 _instance = self.form.save(commit=False) 247 import pdb; pdb.set_trace() ;248 247 _instance.masterip = freeMasterIP(_instance.network) 249 248 _instance.save()
Note:
See TracChangeset
for help on using the changeset viewer.