test_apidirectory.py 998 Bytes
Newer Older
1
2
3
4
import unittest
from apidirectory import ApiDirectory


John C Boufford's avatar
John C Boufford committed
5
# Test calling the API tirectory.
6
class ApiDirectoryTest(unittest.TestCase):
Kyle Cochrane's avatar
Kyle Cochrane committed
7
8
    client_id = "some-guid-goes-here"
    secret = "secret-string-goes-here"
9
10
11
    scope = "iamgroups"
    token_url = "https://apigw-tst.it.umich.edu/um/inst/oauth2/token"

John C Boufford's avatar
John C Boufford committed
12
    # Test the construtor.
13
    def test_constructor(self):
John C Boufford's avatar
John C Boufford committed
14
        api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url)
15
16
17
18
19
        self.assertEqual(api.client_id, self.client_id)
        self.assertEqual(api.secret, self.secret)
        self.assertEqual(api.scope, self.scope)
        self.assertEqual(api.token_url, self.token_url)
        self.assertEqual(api.timeout, 10)
20

John C Boufford's avatar
John C Boufford committed
21
    # Test the header.
22
    def test_build_header(self):
John C Boufford's avatar
John C Boufford committed
23
        api = ApiDirectory(self.client_id, self.secret, self.scope, self.token_url)
24
25

        header = api.build_headers()
John C Boufford's avatar
John C Boufford committed
26
        self.assertEqual(header['x-ibm-client-id'], self.client_id)
John C Boufford's avatar
John C Boufford committed
27
        self.assertTrue('authorization' in header)