Skip to content

Commit

Permalink
created tests for drone
Browse files Browse the repository at this point in the history
  • Loading branch information
mdk6jd committed Oct 7, 2016
1 parent b2dea56 commit 344e13b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
50 changes: 50 additions & 0 deletions models/daasapp/tests/test_drones.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from django.test import TestCase, Client
from django.forms import ModelForm
from django.core.urlresolvers import reverse
from .. import models
from .. import views
import json
import datetime
import random

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

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',
'last_checked_out': datetime.datetime.now(),
#owner': {'user_id': 300, 'f_name': 'Mark', 'date_joined': datetime.datetime.now(), 'email_address': '[email protected]', 'username': 'abolishputamen100', 'bio': "a little about me: I'm pitter-patter, limiting, zoonal, ", 'l_name': 'White', 'is_active': True, 'password': 'Lettish_fundamentalism100'},
'permissions': 'you can this and wintery with my drone, but NOT pygmoid, or 100.',
'maintenance_status': "my drone is in great condition! 100.",
'available_for_hire': True,
'owner_email': '[email protected]',
'battery_level': 100.0,
'model_name': 'prehistorians_inexpugnably100' }

c = Client()
response = c.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}))
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}))
resp = json.loads(response.content.decode('utf8'))
self.assertEquals(resp["ok"], False)

def tearDown(self):
pass
2 changes: 1 addition & 1 deletion models/daasapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def create_drone(request): # /api/v1/drone/create
except db.Error:
return _error_response(request, "db error")

return _success_response(request, {'drone_id': new_drone.pk})
return _success_response(request, {'drone_id': d.pk})


def inspect_drone(request, drone_id): # /api/v1/drone/<drone_id>
Expand Down
7 changes: 6 additions & 1 deletion web/daasapp/templates/web/lets-grade.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ <h3 class="list-group-item-heading">Navigating</h3>
<li class="list-group-item list-group-item-info">
<h3 class="list-group-item-heading">User Stories</h3>
<p class="list-group-item-text">
<code>Donec id elit</code> non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
<p> 1. As a user, I would like to be able to create a user profile. </p>
<p> 2. As a user, I would like to be able to retrieve my own information and see other user's profiles. </p>
<p> 3. As a user, I would like to get information on a drone. </p>
<p> 4. As a user, I would like to have a biography section to express myself. </p>
<p> 5. As a user, I would like to show people how long I've been on the site. </p>
<p> 6. As a user, I would like to see a list of drones I am currently loaning out. </p>
</p>
</li>

Expand Down

0 comments on commit 344e13b

Please sign in to comment.