Skip to content

Commit b784552

Browse files
committed
feature/sdk_python#149 Clean up.
1 parent bea7c99 commit b784552

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

Diff for: bunq/sdk/util/util.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from bunq.sdk.context.api_context import ApiContext, ApiEnvironmentType
99
from bunq.sdk.exception.bunq_exception import BunqException
1010
from bunq.sdk.http.api_client import ApiClient
11-
from bunq.sdk.model.generated import endpoint
1211
from bunq.sdk.model.generated.endpoint import SandboxUserPerson
1312

1413
__UNIQUE_REQUEST_ID = "uniqueness-is-required"
@@ -17,16 +16,15 @@
1716
__FIELD_RESPONSE = "Response"
1817
__ENDPOINT_SANDBOX_USER_PERSON = "sandbox-user-person"
1918

19+
# Error constants
2020
_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER = "Could not create new sandbox user."
21+
_ERROR_ALL_FIELD_IS_NULL = 'All fields are null'
2122

2223

2324
def automatic_sandbox_install() -> ApiContext:
2425
sandbox_user = __generate_new_sandbox_user()
2526

26-
return ApiContext.create(ApiEnvironmentType.SANDBOX,
27-
sandbox_user.api_key,
28-
socket.gethostname()
29-
)
27+
return ApiContext.create(ApiEnvironmentType.SANDBOX, sandbox_user.api_key, socket.gethostname())
3028

3129

3230
def __generate_new_sandbox_user() -> SandboxUserPerson:
@@ -44,8 +42,7 @@ def __generate_new_sandbox_user() -> SandboxUserPerson:
4442

4543
if response.status_code is ApiClient.STATUS_CODE_OK:
4644
response_json = json.loads(response.text)
47-
return SandboxUserPerson.from_json(
48-
json.dumps(response_json[__FIELD_RESPONSE][__INDEX_FIRST][
49-
__FIELD_API_KEY]))
45+
46+
return SandboxUserPerson.from_json(json.dumps(response_json[__FIELD_RESPONSE][__INDEX_FIRST][__FIELD_API_KEY]))
5047

5148
raise BunqException(_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER)

Diff for: tests/context/test_api_context.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ class TestApiContext(BunqSdkTestCase):
2323
def setUpClass(cls) -> None:
2424
super().setUpClass()
2525
cls._FILE_MODE_READ = ApiContext._FILE_MODE_READ
26-
cls._API_CONTEXT = cls._get_api_context()
27-
cls._TMP_FILE_PATH_FULL = (cls._get_directory_test_root() +
28-
cls._TMP_FILE_PATH)
26+
cls._API_CONTEXT: ApiContext = cls._get_api_context()
27+
cls._TMP_FILE_PATH_FULL = (cls._get_directory_test_root() + cls._TMP_FILE_PATH)
2928

30-
def test_api_context_save(self):
29+
def test_api_context_save(self) -> None:
3130
"""
3231
Converts an ApiContext to JSON data, saves the same ApiContext to a
3332
temporary file, and compares whether the JSON data is equal to the
@@ -47,7 +46,7 @@ def test_api_context_save(self):
4746

4847
self.assertEqual(context_retrieved, context_json)
4948

50-
def test_api_context_restore(self):
49+
def test_api_context_restore(self) -> None:
5150
"""
5251
Saves an ApiContext to a temporary file, restores an ApiContext from
5352
that file, and compares whether the api_keys, tokens, and environment

0 commit comments

Comments
 (0)