-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathconftest.py
More file actions
52 lines (37 loc) · 1.33 KB
/
conftest.py
File metadata and controls
52 lines (37 loc) · 1.33 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import httpx
import pytest
from kiota_abstractions.authentication import AnonymousAuthenticationProvider
from msgraph_core import APIVersion, NationalClouds
from msgraph_core.graph_client_factory import GraphClientFactory
from msgraph_core.middleware import GraphRequestContext
BASE_URL = NationalClouds.Global + '/' + APIVersion.v1
class MockAuthenticationProvider(AnonymousAuthenticationProvider):
async def get_authorization_token(self, request: httpx.Request) -> str:
"""Returns a string representing a dummy token
Args:
request (GraphRequest): Graph request object
"""
request.headers['Authorization'] = 'Sample token'
return
@pytest.fixture
def mock_auth_provider():
return MockAuthenticationProvider()
@pytest.fixture
def mock_transport():
client = GraphClientFactory.create_with_default_middleware()
return client._transport
@pytest.fixture
def mock_request():
req = httpx.Request('GET', "https://example.org")
req.options = {}
return req
@pytest.fixture
def mock_graph_request():
req = httpx.Request('GET', BASE_URL)
req.context = GraphRequestContext({}, req.headers)
return req
@pytest.fixture
def mock_response():
return httpx.Response(
json={'message': 'Success!'}, status_code=200, headers={"Content-Type": "application/json"}
)