Skip to content

Commit 7810de1

Browse files
committed
Refactor directory structure to enable 'from msgraph.core' import format
1 parent 583a0f5 commit 7810de1

23 files changed

+45
-48
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,12 @@ repos:
2121
name: pylint
2222
stages: [commit]
2323
language: system
24-
entry: pipenv run pylint msgraphcore --disable=W --rcfile=.pylintrc
24+
entry: pipenv run pylint msgraph --disable=W --rcfile=.pylintrc
2525
types: [python]
2626

2727
- id: pytest-unit
2828
name: pytest-unit
2929
stages: [commit]
3030
language: system
31-
entry: pipenv run coverage run -m pytest tests/unit
32-
types: [python]
33-
34-
- id: pytest-integration
35-
name: pytest-integration
36-
stages: [commit]
37-
language: system
38-
entry: pipenv run coverage run -m pytest tests/integration
31+
entry: pipenv run pytest
3932
types: [python]

msgraph/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ------------------------------------
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
# -----------------------------------

msgraph/core/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .client_factory import HTTPClientFactory
2+
from .constants import SDK_VERSION
3+
from .graph_client import GraphClient
4+
5+
__version__ = SDK_VERSION

msgraphcore/client_factory.py renamed to msgraph/core/client_factory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
from requests import Session
55

6-
from msgraphcore.constants import CONNECTION_TIMEOUT, REQUEST_TIMEOUT
7-
from msgraphcore.enums import APIVersion, NationalClouds
8-
from msgraphcore.middleware.abc_token_credential import TokenCredential
9-
from msgraphcore.middleware.authorization import AuthorizationHandler
10-
from msgraphcore.middleware.middleware import BaseMiddleware, MiddlewarePipeline
6+
from .constants import CONNECTION_TIMEOUT, REQUEST_TIMEOUT
7+
from .enums import APIVersion, NationalClouds
8+
from .middleware.abc_token_credential import TokenCredential
9+
from .middleware.authorization import AuthorizationHandler
10+
from .middleware.middleware import BaseMiddleware, MiddlewarePipeline
1111

1212

1313
class HTTPClientFactory:
File renamed without changes.
File renamed without changes.

msgraphcore/graph_client.py renamed to msgraph/core/graph_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from requests import Request, Session
44

5-
from msgraphcore.client_factory import HTTPClientFactory
6-
from msgraphcore.middleware.abc_token_credential import TokenCredential
7-
from msgraphcore.middleware.middleware import BaseMiddleware
8-
from msgraphcore.middleware.request_context import RequestContext
5+
from .client_factory import HTTPClientFactory
6+
from .middleware.abc_token_credential import TokenCredential
7+
from .middleware.middleware import BaseMiddleware
8+
from .middleware.request_context import RequestContext
99

1010
supported_options = ['scopes', 'custom_option']
1111

msgraph/core/middleware/__init__.py

Whitespace-only changes.

msgraphcore/middleware/authorization.py renamed to msgraph/core/middleware/authorization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from msgraphcore.enums import FeatureUsageFlag
2-
from msgraphcore.middleware.abc_token_credential import TokenCredential
3-
from msgraphcore.middleware.middleware import BaseMiddleware
1+
from ..enums import FeatureUsageFlag
2+
from .abc_token_credential import TokenCredential
3+
from .middleware import BaseMiddleware
44

55

66
class AuthorizationHandler(BaseMiddleware):

msgraphcore/middleware/middleware.py renamed to msgraph/core/middleware/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from requests.adapters import HTTPAdapter
55
from urllib3 import PoolManager
66

7-
from msgraphcore.middleware.request_context import RequestContext
7+
from .request_context import RequestContext
88

99

1010
class MiddlewarePipeline(HTTPAdapter):

msgraphcore/middleware/request_context.py renamed to msgraph/core/middleware/request_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import uuid
22

3-
from msgraphcore.enums import FeatureUsageFlag
3+
from ..enums import FeatureUsageFlag
44

55

66
class RequestContext:

msgraphcore/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

samples/samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from azure.identity import InteractiveBrowserCredential
55

6-
from msgraphcore.graph_client import GraphClient
6+
from msgraph.core.graph_client import GraphClient
77

88
scopes = ['user.read']
99
browser_credential = InteractiveBrowserCredential(client_id='YOUR_CLIENT_ID')

tests/__init__.py

Whitespace-only changes.

tests/integration/__init__.py

Whitespace-only changes.

tests/integration/test_graphclient.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import pytest
22
from requests import Session
33

4-
from msgraphcore.enums import APIVersion
5-
from msgraphcore.graph_client import GraphClient
6-
from msgraphcore.middleware.authorization import AuthorizationHandler
4+
from msgraph.core.enums import APIVersion
5+
from msgraph.core.graph_client import GraphClient
6+
from msgraph.core.middleware.authorization import AuthorizationHandler
77

88

99
class _CustomTokenCredential:

tests/integration/test_http_client_factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import pytest
22
from requests import Session
33

4-
from msgraphcore.client_factory import HTTPClientFactory
5-
from msgraphcore.enums import APIVersion
6-
from msgraphcore.middleware.authorization import AuthorizationHandler
4+
from msgraph.core.client_factory import HTTPClientFactory
5+
from msgraph.core.enums import APIVersion
6+
from msgraph.core.middleware.authorization import AuthorizationHandler
77

88

99
class _CustomTokenCredential:

tests/unit/__init__.py

Whitespace-only changes.

tests/unit/test_auth_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

3-
from msgraphcore.middleware.authorization import AuthorizationHandler
4-
from msgraphcore.middleware.request_context import RequestContext
3+
from msgraph.core.middleware.authorization import AuthorizationHandler
4+
from msgraph.core.middleware.request_context import RequestContext
55

66

77
def test_context_options_override_default_scopes():

tests/unit/test_client_factory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from requests import Session
33
from requests.adapters import HTTPAdapter
44

5-
from msgraphcore.client_factory import HTTPClientFactory
6-
from msgraphcore.constants import CONNECTION_TIMEOUT, REQUEST_TIMEOUT
7-
from msgraphcore.enums import APIVersion, NationalClouds
8-
from msgraphcore.middleware.authorization import AuthorizationHandler
9-
from msgraphcore.middleware.middleware import BaseMiddleware, MiddlewarePipeline
5+
from msgraph.core.client_factory import HTTPClientFactory
6+
from msgraph.core.constants import CONNECTION_TIMEOUT, REQUEST_TIMEOUT
7+
from msgraph.core.enums import APIVersion, NationalClouds
8+
from msgraph.core.middleware.authorization import AuthorizationHandler
9+
from msgraph.core.middleware.middleware import BaseMiddleware, MiddlewarePipeline
1010

1111

1212
def test_initialize_with_default_config():

tests/unit/test_graph_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from requests import Session
44
from requests.adapters import HTTPAdapter
55

6-
from msgraphcore.constants import CONNECTION_TIMEOUT, REQUEST_TIMEOUT
7-
from msgraphcore.enums import APIVersion, NationalClouds
8-
from msgraphcore.graph_client import GraphClient
9-
from msgraphcore.middleware.authorization import AuthorizationHandler
10-
from msgraphcore.middleware.middleware import BaseMiddleware, MiddlewarePipeline
6+
from msgraph.core.constants import CONNECTION_TIMEOUT, REQUEST_TIMEOUT
7+
from msgraph.core.enums import APIVersion, NationalClouds
8+
from msgraph.core.graph_client import GraphClient
9+
from msgraph.core.middleware.authorization import AuthorizationHandler
10+
from msgraph.core.middleware.middleware import BaseMiddleware, MiddlewarePipeline
1111

1212

1313
def test_graph_client_with_default_middleware():

tests/unit/test_middleware_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections import OrderedDict
22
from unittest import TestCase
33

4-
from msgraphcore.middleware.middleware import BaseMiddleware, MiddlewarePipeline
4+
from msgraph.core.middleware.middleware import BaseMiddleware, MiddlewarePipeline
55

66

77
class MiddlewarePipelineTest(TestCase):

0 commit comments

Comments
 (0)