-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
38 lines (29 loc) · 997 Bytes
/
tests.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
34
35
36
37
38
from auth import generate_token, validate_token
import unittest
from google.appengine.ext import testbed
from secrets import secret_string
# write your tests here
# run tests with: python tests.py
class TestHandlers(unittest.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
def tearDown(self):
self.testbed.deactivate()
'''
def test_main_handler(self):
request = webapp2.Request.blank('/')
response = request.get_response(app)
self.assertEqual(response.status_int, 200)
self.assertEqual(response.body, 'Hello, world!')
'''
def test_token(self):
token = generate_token(userid='12345', secret=secret_string)
self.assertTrue(validate_token(token=token, secret=secret_string))
# key part - don't delete
def main():
unittest.main()
if __name__ == '__main__':
main()