forked from lvasiliev/smstools-http-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·31 lines (23 loc) · 939 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from app import create_app
import unittest
import base64
user_credentials = base64.b64encode(b'test:test').decode('utf-8')
class AppTestCase(unittest.TestCase):
def setUp(self):
self.app = create_app('test')
self.client = self.app.test_client()
def tearDown(self):
pass
def test_app_configuration(self):
self.assertTrue(self.app.config['TESTING'])
def test_unauthorized_access(self):
response = self.client.get('/api/v1.0/sms/sent/test')
self.assertTrue('Unauthorized access' in response.get_data(as_text=True))
def test_authorized_access(self):
headers = {"Authorization": "Basic {}".format(user_credentials)}
response = self.client.get('/api/v1.0/sms/sent/test', headers=headers)
self.assertTrue('Not found' in response.get_data(as_text=True))
if __name__ == '__main__':
unittest.main()