Skip to content

Commit 1d2405c

Browse files
authored
[ BB2-1288 ] Code cleanup (Linting & Style) (#10)
* Update .py files with black & flake8 * Remove not needed name & verbose_name
1 parent 660bfca commit 1d2405c

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

cms_bluebutton/cms_bluebutton.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323

2424
class BlueButton:
25-
name = "bb2"
26-
verbose_name = "Blue Button 2.0 SDK Package"
2725

2826
def __init__(self, config=DEFAULT_CONFIG_FILE_LOCATION):
2927
self.client_id = None
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
TOKEN_RESPONSE = {'access_token': 'sj27kLVRk2sQeLqSKFte5T5pgKM78U', 'expires_in': 36000, 'token_type': 'Bearer', 'scope': 'introspection patient/Coverage.read patient/ExplanationOfBenefit.read patient/Patient.read profile', 'refresh_token': 'QjqsforutTRf8IV8Z0GT7KcAZb4099', 'patient': '-19990000000001'}
2-
REFRESH_TOKEN_RESPONSE = {'access_token': 'sj27kLVRk2sQeLqSKFte5T5pgKM78U-refrehed', 'expires_in': 36000, 'token_type': 'Bearer', 'scope': 'introspection patient/Coverage.read patient/ExplanationOfBenefit.read patient/Patient.read profile', 'refresh_token': 'QjqsforutTRf8IV8Z0GT7KcAZb4099-refreshed', 'patient': '-19990000000001'}
1+
TOKEN_RESPONSE = {
2+
"access_token": "sj27kLVRk2sQeLqSKFte5T5pgKM78U",
3+
"expires_in": 36000,
4+
"token_type": "Bearer",
5+
"scope": "introspection patient/Coverage.read patient/ExplanationOfBenefit.read patient/Patient.read profile",
6+
"refresh_token": "QjqsforutTRf8IV8Z0GT7KcAZb4099",
7+
"patient": "-19990000000001",
8+
}
9+
REFRESH_TOKEN_RESPONSE = {
10+
"access_token": "sj27kLVRk2sQeLqSKFte5T5pgKM78U-refrehed",
11+
"expires_in": 36000,
12+
"token_type": "Bearer",
13+
"scope": "introspection patient/Coverage.read patient/ExplanationOfBenefit.read patient/Patient.read profile",
14+
"refresh_token": "QjqsforutTRf8IV8Z0GT7KcAZb4099-refreshed",
15+
"patient": "-19990000000001",
16+
}

cms_bluebutton/tests/test_configs.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ def test_invalid_file_extension():
1010
# Test extension not matching .json or .yaml
1111
with pytest.raises(
1212
ValueError,
13-
match=r"Error: Configuration file extension"
14-
" must be .json or .yaml for:.*",
13+
match=r"Error: Configuration file extension" " must be .json or .yaml for:.*",
1514
):
1615
BlueButton(config="file.xxx")
1716

1817

1918
def test_read_config_json_equals_yaml():
20-
bb = BlueButton(config=CONFIGS_DIR +
21-
"json/bluebutton-sample-config-valid-sbx.json")
19+
bb = BlueButton(config=CONFIGS_DIR + "json/bluebutton-sample-config-valid-sbx.json")
2220

2321
# Test dict's are equal for both JSON & YAML
2422
assert bb._read_config(
@@ -30,17 +28,17 @@ def test_read_config_json_equals_yaml():
3028

3129
def test_valid_config():
3230
# valid config sbx
33-
bb = BlueButton(config=CONFIGS_DIR +
34-
"json/bluebutton-sample-config-valid-sbx.json")
31+
bb = BlueButton(config=CONFIGS_DIR + "json/bluebutton-sample-config-valid-sbx.json")
3532
assert bb.base_url == "https://sandbox.bluebutton.cms.gov"
3633
assert bb.client_id == "<your BB2 client_id here>"
3734
assert bb.client_secret == "<your BB2 client_secret here>"
3835
assert bb.callback_url == "https://www.fake-sandbox.com/your/callback/here"
3936
assert bb.version == 1
4037

4138
# valid config prod
42-
bb = BlueButton(config=CONFIGS_DIR +
43-
"json/bluebutton-sample-config-valid-prod.json")
39+
bb = BlueButton(
40+
config=CONFIGS_DIR + "json/bluebutton-sample-config-valid-prod.json"
41+
)
4442
assert bb.base_url == "https://api.bluebutton.cms.gov"
4543
assert bb.client_id == "<your BB2 client_id here>"
4644
assert bb.client_secret == "<your BB2 client_secret here>"
@@ -80,8 +78,7 @@ def test_config_setting_missing():
8078
for setting, file_name in [
8179
["client_id", "json/bluebutton-sample-config-missing-id.json"],
8280
["client_secret", "json/bluebutton-sample-config-missing-secret.json"],
83-
["callback_url",
84-
"json/bluebutton-sample-config-missing-callback.json"],
81+
["callback_url", "json/bluebutton-sample-config-missing-callback.json"],
8582
]:
8683
with pytest.raises(
8784
ValueError,
@@ -92,6 +89,7 @@ def test_config_setting_missing():
9289

9390

9491
def test_config_version_missing_defaults_to_v2():
95-
bb = BlueButton(config=CONFIGS_DIR +
96-
"json/bluebutton-sample-config-missing-version.json")
92+
bb = BlueButton(
93+
config=CONFIGS_DIR + "json/bluebutton-sample-config-missing-version.json"
94+
)
9795
assert bb.version == 2

cms_bluebutton/tests/test_fhir_request.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ def not_found_fhir_request_mock(*args, **kwargs):
6161
def generate_mock_config():
6262
return {
6363
"params": {},
64-
"auth_token": AuthorizationToken({
65-
"access_token": "fake_access_token",
66-
"refresh_token": "fake_refresh_token",
67-
"expires_at": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(seconds=36000),
68-
"patient": "-20140000010000",
69-
}),
64+
"auth_token": AuthorizationToken(
65+
{
66+
"access_token": "fake_access_token",
67+
"refresh_token": "fake_refresh_token",
68+
"expires_at": datetime.datetime.now(datetime.timezone.utc)
69+
+ datetime.timedelta(seconds=36000),
70+
"patient": "-20140000010000",
71+
}
72+
),
7073
}
7174

7275

0 commit comments

Comments
 (0)