-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (22 loc) · 879 Bytes
/
Copy pathtest.py
File metadata and controls
28 lines (22 loc) · 879 Bytes
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
import unittest
import json
from main import app
class ChatApiTestCase(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
self.app.testing = True
def test_api_index(self):
response = self.app.get('/api/')
self.assertEqual(response.status_code, 200)
data = response.get_json()
self.assertEqual(data.get("name"), "eddi.chat API")
def test_unauthorized_access(self):
response = self.app.get('/api/me')
self.assertEqual(response.status_code, 401)
def test_login_validation(self):
response = self.app.post('/api/auth/login',
data=json.dumps({"username": "", "password": ""}),
content_type='application/json')
self.assertEqual(response.status_code, 400)
if __name__ == '__main__':
unittest.main()