Skip to content

Commit

Permalink
integrated setUp and tearDown with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdk6jd committed Oct 7, 2016
1 parent 344e13b commit 1f82c6e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
20 changes: 11 additions & 9 deletions models/daasapp/tests/test_drones.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

class DroneFormTests(TestCase):
fixtures = ['db'] # load from DB

def setUp(self):
pass
self.client = Client()

def test_DroneForm(self):
form_data = {'_owner_key': 50, 'drone_desc': 'velutinous peg-top Mesopotamia rakees lecherously and 100.',
#'drone_id': 100,
'demo_link': 'http://demo_pacific100.com',
Expand All @@ -25,26 +25,28 @@ def test_DroneForm(self):
'battery_level': 100.0,
'model_name': 'prehistorians_inexpugnably100' }

c = Client()
response = c.post(reverse('create_drone'), form_data)
response = self.client.post(reverse('create_drone'), form_data)
print("test_create_drone POST " + str(response))

resp = json.loads(response.content.decode('utf8'))
self.assertEquals(response.status_code, 200)
print("drone_atts" + str(resp))

response = c.get(reverse('inspect_drone', kwargs={'drone_id':201}))
# append number to test to get python to run defs in correct order
def test1_DroneForm(self):

response = self.client.get(reverse('inspect_drone', kwargs={'drone_id':201}))
resp = json.loads(response.content.decode('utf8'))

print("test_drone_attributes GET " + str(resp))
self.assertEquals(resp["ok"],True)
self.assertEquals(resp['resp']['model_name'], 'prehistorians_inexpugnably100')

def test_drone_invalid(self):
c = Client()
response = c.get(reverse('inspect_drone', kwargs={'drone_id':300}))
def test2_Drone_Invalid_id(self):
response = self.client.get(reverse('inspect_drone', kwargs={'drone_id':300}))
resp = json.loads(response.content.decode('utf8'))
self.assertEquals(resp["ok"], False)


def tearDown(self):
pass
del self.client
26 changes: 12 additions & 14 deletions models/daasapp/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,32 @@ def tearDown(self):

class InspectUserTestCase(TestCase):
fixtures = ['db'] # load from DB

def setUp(self):
pass

def test_user_attributes(self):
#add users
c = Client()

self.client = Client()
user_name = random.randrange(0,200)
c = Client()
form_data = {'username': 'abolishputa'+str(user_name),'password': 'Lettish_fundamentalism100', 'email_address': '[email protected]','date_joined': datetime.datetime.now(), 'is_active': True, 'f_name': 'Mark', 'l_name': 'White','bio': "a zoonal" }

form = views.UserForm(data=form_data)
self.assertTrue(form.is_valid())
response = c.post(reverse('create_user'), form_data)
print("test_user_attributes POST " + str(response))

response = self.client.post(reverse('create_user'), form_data)
print("test_user_attributes POST " + str(response))

resp = json.loads(response.content.decode('utf8'))
print("user atts " + str(resp))
self.assertEquals(response.status_code, 200)

response = c.get(reverse('inspect_user', kwargs={'user_id':201}))
# append number to test to get python to run defs in correct order
def test1_user_attributes(self):

response = self.client.get(reverse('inspect_user', kwargs={'user_id':201}))
resp = json.loads(response.content.decode('utf8'))

print("test_user_attributes GET " + str(resp))
self.assertEquals(resp["ok"],True)
self.assertEquals(resp['resp']['f_name'], 'Mark')
def test_fails_invalid(self):

def test2_fails_invalid_user(self):
response = self.client.get(reverse('inspect_user', kwargs=None))
self.assertEquals(response.status_code, 200)

Expand All @@ -64,7 +62,7 @@ def test_fails_invalid(self):
self.assertEquals(resp["ok"],False)

def tearDown(self):
pass
del self.client

#experience tests bonus
#this project is read ony?
Expand Down

0 comments on commit 1f82c6e

Please sign in to comment.