Skip to content

Commit c1092f6

Browse files
author
James Fuqian
authored
Merge pull request #29 from CMSgov/jfuqian/BB2-2080-python-SDK-add-support-for-LOCAL-env
[BB2-2080] Python SDK Add Support for LOCAL and TEST target ENV
2 parents fcaad64 + 1f43d83 commit c1092f6

6 files changed

Lines changed: 37 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ There are three ways to configure the SDK when instantiating a `BlueButton` clas
120120
"backoff_factor": 5,
121121
"status_forcelist": [500, 502, 503, 504]
122122
}
123-
}
123+
})
124124
```
125125
### JSON config file
126126
- This is using a configuration file that is in a JSON format.

cms_bluebutton/cms_bluebutton.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ def set_configuration(self, config):
6969

7070
# Check environment setting
7171
env = config_dict.get("environment", None)
72-
if env in ["SANDBOX", "PRODUCTION"]:
72+
if env in ["LOCAL", "TEST", "SANDBOX", "PRODUCTION"]:
7373
self.base_url = ENVIRONMENT_URLS.get(env, None)
7474
else:
7575
raise ValueError(
7676
"Error: Configuration environment must be set to"
77-
" SANDBOX or PRODUCTION in: {}".format(config)
77+
" LOCAL or TEST or SANDBOX or PRODUCTION in: {}".format(config)
7878
)
7979

8080
# Check other settings are provided

cms_bluebutton/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
REFRESH_TOKEN_ENDPOINT = "/o/token/"
1010

1111
ENVIRONMENT_URLS = {
12+
"LOCAL": "http://localhost:8000",
13+
"TEST": "https://test.bluebutton.cms.gov",
1214
"SANDBOX": "https://sandbox.bluebutton.cms.gov",
1315
"PRODUCTION": "https://api.bluebutton.cms.gov",
1416
}

cms_bluebutton/tests/test_configs.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ def test_read_config_json_equals_yaml():
2727

2828

2929
def test_valid_config():
30+
# valid config local env
31+
bb = BlueButton(config=CONFIGS_DIR + "json/bluebutton-sample-config-valid-local.json")
32+
assert bb.base_url == "http://localhost:8000"
33+
assert bb.client_id == "<your BB2 client_id here>"
34+
assert bb.client_secret == "<your BB2 client_secret here>"
35+
assert bb.callback_url == "https://fake-local/your/callback/here"
36+
assert bb.version == 1
37+
38+
# valid config test env
39+
bb = BlueButton(config=CONFIGS_DIR + "json/bluebutton-sample-config-valid-test.json")
40+
assert bb.base_url == "https://test.bluebutton.cms.gov"
41+
assert bb.client_id == "<your BB2 client_id here>"
42+
assert bb.client_secret == "<your BB2 client_secret here>"
43+
assert bb.callback_url == "https://www.fake-test.com/your/callback/here"
44+
assert bb.version == 1
45+
3046
# valid config sbx
3147
bb = BlueButton(config=CONFIGS_DIR + "json/bluebutton-sample-config-valid-sbx.json")
3248
assert bb.base_url == "https://sandbox.bluebutton.cms.gov"
@@ -53,6 +69,7 @@ def test_valid_config():
5369
"callback_url": "https://www.fake-prod.com/your/callback/here",
5470
"version": 1,
5571
}
72+
5673
bb = BlueButton(config_dict)
5774
assert bb.base_url == "https://api.bluebutton.cms.gov"
5875
assert bb.client_id == "<your BB2 client_id here>"
@@ -95,7 +112,7 @@ def test_config_setting_environment():
95112
with pytest.raises(
96113
ValueError,
97114
match=r"Error: Configuration environment must"
98-
" be set to SANDBOX or PRODUCTION in:.*",
115+
" be set to LOCAL or TEST or SANDBOX or PRODUCTION in:.*",
99116
):
100117
BlueButton(config=CONFIGS_DIR + file_name)
101118

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"environment": "LOCAL",
3+
"client_id": "<your BB2 client_id here>",
4+
"client_secret": "<your BB2 client_secret here>",
5+
"callback_url": "https://fake-local/your/callback/here",
6+
"version": 1
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"environment": "TEST",
3+
"client_id": "<your BB2 client_id here>",
4+
"client_secret": "<your BB2 client_secret here>",
5+
"callback_url": "https://www.fake-test.com/your/callback/here",
6+
"version": 1
7+
}

0 commit comments

Comments
 (0)