-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.py
33 lines (23 loc) · 1.03 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import unittest
from google.appengine.ext import testbed
from models import StarTrip
class DemoTestCase(unittest.TestCase):
def setUp(self):
# First, create an instance of the Testbed class.
self.testbed = testbed.Testbed()
# Then activate the testbed, which prepares the service stubs for use.
self.testbed.activate()
# Next, declare which service stubs you want to use.
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
def tearDown(self):
self.testbed.deactivate()
def test_star_trip_creation_from_request(self):
request = {'description': 'It is a trap!', 'origin': 'Coruscant',
'destiny': 'Alderaan', 'price': '500', 'date': '2016-05-09',
'seats': 5}
StarTrip.save_from_request(request)
self.assertEqual(1, StarTrip.query().count(), 'wrong StarTrip count in database')
self.assertEqual(1, 0, '1 is not 0? oh wait, wrong test')
if __name__ == '__main__':
unittest.main()