-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_mgr_api.py
34 lines (24 loc) · 1.04 KB
/
test_mgr_api.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
import json
import unittest
from mgr_api.api import (MGRASTException, MGRASTAuthenticationException,
mgrast_request, id_check)
class Test_api(unittest.TestCase):
def setUp(self):
pass
def test_mgrast_request_invalid_key(self):
try:
req = mgrast_request('project', 'mgp6271', {'verbosity':'full'},
'invalid_key')
except MGRASTAuthenticationException as me:
self.assertIn( 'invalid webkey', me.message)
def test_mgrast_request_insufficient_permissions(self):
try:
req = mgrast_request('project', 'mgp6271', {'verbosity':'full'}, '')
except MGRASTAuthenticationException as me:
self.assertIn( 'insufficient permissions', me.message)
def test_id_check_missing(self):
self.assertEqual(id_check('mgp','1234'), 'mgp1234')
def test_id_check_present(self):
self.assertEqual(id_check('mgp','mgp1234'), 'mgp1234')
if __name__ == '__main__':
unittest.main()