-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest.py
32 lines (22 loc) · 856 Bytes
/
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
import unittest
import json
from app import app
POST_URL = 'http://127.0.0.1:5000/api/post'
GET_URL = 'http://127.0.0.1:5000/api/get'
class PostConfessionTest(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def test_successfull_confession(self):
payload = json.dumps({
"name": "xyz",
"message": "This is a dummy confession"
})
response = self.app.post(POST_URL, data=payload,
content_type='application/json')
self.assertEqual(201, response.status_code)
class GetConfessionTest(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def test_successfull_confession(self):
response = self.app.get(GET_URL, content_type='application/json')
self.assertEqual(200, response.status_code)