test_apidirectory.py 1.02 KB
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
7
8
9
10
11
class ApiDirectoryTest(unittest.TestCase):
    client_id = "e06fb405-c58e-4334-b746-dd5969575bf2"
    secret = "G5oT3vL1uK8xS7rO5sJ4nH7bK5iB6hN5jN5dI0nL8tO5bG4tT5"
    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)