Skip to content

Commit f05134a

Browse files
Renamed 'filename' parameter in Config initializer back to 'file'.
1 parent f34e62a commit f05134a

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

connect/config.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,42 @@
1212
class Config(object):
1313
_instance = None # Global instance
1414

15+
# noinspection PyShadowingBuiltins
1516
def __init__(
1617
self,
1718
api_url=None,
1819
api_key=None,
1920
products=None,
20-
filename=None
21+
file=None
2122
):
2223
"""
2324
initialization config for public api
2425
:param api_url: Public api url
2526
:param api_key: Service user ApiKey
2627
:param products (optional): Id products
27-
:param filename: Config file path
28+
:param file: Config file path
2829
"""
2930
# Check arguments
30-
if not filename and not any([api_key, api_url]):
31+
if not file and not any([api_key, api_url]):
3132
raise ValueError('Filename or api_key and api_url are expected'
3233
'in Config initialization')
3334
if products and not isinstance(products, (str, list)):
3435
raise TypeError('Products can be string or string list. Found type '
3536
+ type(products).__name__)
3637

3738
# Load config from file name
38-
if filename:
39-
if not os.path.exists(filename):
40-
raise IOError('No filename `{}` on directory'.format(filename))
39+
if file:
40+
if not os.path.exists(file):
41+
raise IOError('No file `{}` on directory'.format(file))
4142

42-
with open(filename) as config_file:
43+
with open(file) as config_file:
4344
configs = config_file.read()
4445

4546
try:
4647
configs = json.loads(configs)
4748
except Exception as ex:
48-
raise TypeError('Invalid config filename `{}`\n'
49-
'ERROR: {}'.format(filename, str(ex)))
49+
raise TypeError('Invalid config file `{}`\n'
50+
'ERROR: {}'.format(file, str(ex)))
5051

5152
(api_url, api_key, products) = (configs.get('apiEndpoint', ''),
5253
configs.get('apiKey', ''),
@@ -71,7 +72,7 @@ def __init__(
7172
@classmethod
7273
def get_instance(cls):
7374
if not cls._instance:
74-
cls._instance = Config(filename='config.json')
75+
cls._instance = Config(file='config.json')
7576
return cls._instance
7677

7778
@property

example/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
logger.setLevel("DEBUG")
1616

1717
# If we remove this line, it is done implicitly
18-
Config(filename='config.json')
18+
Config(file='config.json')
1919

2020

2121
class ExampleRequestProcessor(FulfillmentAutomation):

tests/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def test_global_config_immutable_properties():
4646

4747
def test_init_config_with_non_existing_file():
4848
with pytest.raises(IOError):
49-
Config(filename='non_existing_config.json')
49+
Config(file='non_existing_config.json')
5050

5151

5252
def test_init_config_with_file():
53-
_assert_config(Config(filename='config.json'))
53+
_assert_config(Config(file='config.json'))
5454

5555

5656
def test_init_config_with_arguments():
@@ -72,7 +72,7 @@ def test_init_config_with_invalid_arguments():
7272

7373
# noinspection PyPropertyAccess
7474
def test_config_immutable_properties():
75-
config = Config(filename='config.json')
75+
config = Config(file='config.json')
7676
with pytest.raises(AttributeError):
7777
config.api_key = conf_dict.get('apiKey')
7878
config.api_url = conf_dict.get('apiEndpoint')

0 commit comments

Comments
 (0)