-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.py
47 lines (34 loc) · 1.4 KB
/
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
39
40
41
42
43
44
45
46
47
import unittest
from app import app
class TestCase(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def test_save(self):
result = self.app.post('/save', data={'title': 'titulo', 'content': 'test'})
self.assertEqual(result.data, b'test')
self.assertEqual(result.status_code, 200)
def test_fetchall(self):
result = self.app.get('/fetchall')
self.assertEqual(result.data, b'')
self.assertEqual(result.status_code, 200)
self.app.post('/save', data={'title': 'titulo', 'content': 'test'})
result = self.app.get('/fetchall')
self.assertEqual(result.data, b'test')
self.assertEqual(result.status_code, 200)
def test_fetchsingle(self):
result = self.app.get('/fetch/asd')
self.assertEqual(result.status_code, 404)
self.app.post('/save', data={'title': 'asd', 'content': 'test'})
result = self.app.get('/fetch/asd')
self.assertEqual(result.data, b'test')
self.assertEqual(result.status_code, 200)
def test_clear(self):
self.app.post('/save', data={'title': 'asd', 'content': 'test'})
result = self.app.get('/clear')
result = self.app.get('/fetchall')
self.assertEqual(result.data, b'')
self.assertEqual(result.status_code, 200)
def tearDown(self):
pass
if __name__ == '__main__':
unittest.main()