Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
moved utility functions from __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Aug 24, 2016
1 parent 0818f20 commit d373bc8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
25 changes: 0 additions & 25 deletions mkmsdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +0,0 @@
import os
from . import exceptions


def _get_env_var(key):
try:
return os.environ[key]
except KeyError:
raise exceptions.MissingConfig('Missing MKM env var: ' + key)


def get_mkm_app_token():
return _get_env_var('MKM_APP_TOKEN')


def get_mkm_app_secret():
return _get_env_var('MKM_APP_SECRET')


def get_mkm_access_token():
return _get_env_var('MKM_ACCESS_TOKEN')


def get_mkm_access_token_secret():
return _get_env_var('MKM_ACCESS_TOKEN_SECRET')
2 changes: 1 addition & 1 deletion mkmsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from .MKMClient import MKMClient
from . import exceptions
from . import get_mkm_app_token, get_mkm_app_secret, get_mkm_access_token, get_mkm_access_token_secret
from .utils import get_mkm_app_token, get_mkm_app_secret, get_mkm_access_token, get_mkm_access_token_secret
from .MKMOAuth1 import MKMOAuth1
from .api_map import _API_MAP

Expand Down
25 changes: 25 additions & 0 deletions mkmsdk/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
from . import exceptions


def _get_env_var(key):
try:
return os.environ[key]
except KeyError:
raise exceptions.MissingConfig('Missing MKM env var: ' + key)


def get_mkm_app_token():
return _get_env_var('MKM_APP_TOKEN')


def get_mkm_app_secret():
return _get_env_var('MKM_APP_SECRET')


def get_mkm_access_token():
return _get_env_var('MKM_ACCESS_TOKEN')


def get_mkm_access_token_secret():
return _get_env_var('MKM_ACCESS_TOKEN_SECRET')
4 changes: 2 additions & 2 deletions tests/tests_unit/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mkmsdk.MKMClient import MKMClient
from mkmsdk.api import Api
from mkmsdk import exceptions
from mkmsdk import get_mkm_app_secret
from mkmsdk.utils import get_mkm_app_secret


def test_create_auth():
Expand Down Expand Up @@ -39,7 +39,7 @@ def test_create_auth_with_empty_string_token():


def test_missing_env_var_raise_exception_correctly(mocker):
os_mocked = mocker.patch('mkmsdk.os')
os_mocked = mocker.patch('mkmsdk.utils.os')
os_mocked.environ = {}
with pytest.raises(exceptions.MissingConfig):
get_mkm_app_secret()
Expand Down

0 comments on commit d373bc8

Please sign in to comment.