forked from vgrem/office365-rest-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_case.py
More file actions
29 lines (22 loc) · 797 Bytes
/
graph_case.py
File metadata and controls
29 lines (22 loc) · 797 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
29
from unittest import TestCase
import adal
from settings import settings
from office365.graph_client import GraphClient
def get_token():
"""
Get token
"""
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
auth_ctx = adal.AuthenticationContext(authority_url)
token = auth_ctx.acquire_token_with_username_password(
'https://graph.microsoft.com',
settings['user_credentials']['username'],
settings['user_credentials']['password'],
settings['client_credentials']['client_id'])
return token
class GraphTestCase(TestCase):
"""Microsoft Graph specific test case base class"""
client = None # type: GraphClient
@classmethod
def setUpClass(cls):
cls.client = GraphClient(get_token)