/
test_model.py
30 lines (24 loc) · 1012 Bytes
/
test_model.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
import unittest
from google.appengine.ext import ndb
from google.appengine.ext import testbed
from models import Workflow
class ModelTestCase(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()
# Clear ndb's in-context cache between tests.
# This prevents data from leaking between tests.
# Alternatively, you could disable caching by
# using ndb.get_context().set_cache_policy(False)
ndb.get_context().clear_cache()
def tearDown(self):
self.testbed.deactivate()
def test_workflow_init_defaults(self):
workflow = Workflow(name="Richard's WF")
self.assertEqual(1, workflow.version)
if __name__ == '__main__':
unittest.main()