Skip to content

Commit eeca577

Browse files
committed
cleanup tests; fix README.md
1 parent 6f1019f commit eeca577

13 files changed

+47
-14
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,36 @@ users = generated.User.list(api_context)
146146

147147
##### Example
148148
See [`UserListExample.py`](./examples/user_list_example.py)
149+
150+
## Running Samples
151+
In order to make the experience of getting into bunq Python SDK smoother, we
152+
have bundled it with example use cases (located under `/examples`).
153+
154+
To run an example, please do the following:
155+
1. In your IDE, open the example you are interested in and adjust the constants,
156+
such as `_API_KEY` or `_USER_ID`, to hold your data.
157+
2. In your terminal, go to the root of bunq SDK project:
158+
159+
```shell
160+
$ cd /path/to/bunq/sdk/
161+
```
162+
3. In the terminal, run:
163+
164+
```shell
165+
$ python3 run.py examples/<something_example.py>
166+
```
167+
Replace `<something_example.py>` with the name of the example you would like
168+
to run. If you wish to run the example with python 2, also replace
169+
`python3` with `python`.
170+
171+
In order for examples to run, you would need a valid context file (`bunq.conf`)
172+
to be present in the bunq SDK project root directory. The file can either copied
173+
from somewhere else (e.g. tests) or created by running the following command
174+
in your bunq SDK project root directory:
175+
176+
```shell
177+
$ python3 run.py examples/api_context_save_example.py
178+
```
179+
180+
Please do not forget to set the `_API_KEY` constant in
181+
`api_context_save_example.py` to your actual API key before running the sample!

tests/assets/config.example.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"API_KEY": "<API KEY>",
33
"USER_ID": "xxxx",
4-
"MA_ID": "xxxx",
5-
"MA_ID2": "xxxx",
4+
"MONETARY_ACCOUNT_ID": "xxxx",
5+
"MONETARY_ACCOUNT_ID2": "xxxx",
66
"ipAddress": "<Ip address>",
77
"AttachmentPublicTest":{
88
"CONTENT_TYPE": "image/png",

tests/bunq_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BunqSdkTestCase(unittest.TestCase):
1919
_DEVICE_DESCRIPTION = 'Python test device'
2020

2121
@classmethod
22-
def get_api_context(cls):
22+
def _get_api_context(cls):
2323
"""
2424
Calls IsSessionActive to check if the session token is still active
2525
and returns the ApiContext.

tests/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Config:
1212
_FIELD_ALIAS = "Alias"
1313
_FIELD_TAB_USAGE = "TabUsageSingleTest"
1414
_FIELD_CASH_REGISTER_ID = "CASH_REGISTER_ID"
15-
_FIELD_MONETARY_ACCOUNT_ID_1 = "MA_ID"
16-
_FIELD_MONETARY_ACCOUNT_ID_2 = "MA_ID2"
15+
_FIELD_MONETARY_ACCOUNT_ID_1 = "MONETARY_ACCOUNT_ID"
16+
_FIELD_MONETARY_ACCOUNT_ID_2 = "MONETARY_ACCOUNT_ID2"
1717
_FIELD_USER_ID = "USER_ID"
1818
_FIELD_API_KEY = "API_KEY"
1919
_FIELD_ATTACHMENT_PUBLIC = "AttachmentPublicTest"

tests/model/generated/test_attachment_public.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def setUpClass(cls):
2020
cls._CONTENT_TYPE = Config.get_attachment_content_type()
2121
cls._ATTACHMENT_DESCRIPTION = Config.get_attachment_description()
2222
cls._ATTACHMENT_PATH_IN = Config.get_attachment_path_in()
23-
cls._API_CONTEXT = cls.get_api_context()
23+
cls._API_CONTEXT = cls._get_api_context()
2424

2525
def test_file_upload_and_retrieval(self):
2626
"""

tests/model/generated/test_avatar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def setUpClass(cls):
2222
cls._CONTENT_TYPE = Config.get_attachment_content_type()
2323
cls._ATTACHMENT_DESCRIPTION = Config.get_attachment_description()
2424
cls._ATTACHMENT_PATH_IN = Config.get_attachment_path_in()
25-
cls._API_CONTEXT = cls.get_api_context()
25+
cls._API_CONTEXT = cls._get_api_context()
2626

2727
def test_avatar_creation(self):
2828
"""

tests/model/generated/test_card_debit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def setUpClass(cls):
2525
cls._SECOND_LINE_LENGTH_MAXIMUM = 20
2626
cls._STRING_EMPTY = ''
2727
cls._USER_ID = Config.get_user_id()
28-
cls._API_CONTEXT = cls.get_api_context()
28+
cls._API_CONTEXT = cls._get_api_context()
2929

3030
def test_order_debit_card(self):
3131
"""

tests/model/generated/test_draft_share_invite_bank.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setUpClass(cls):
2323
cls._WRITE_BYTES = 'wb'
2424
cls._EXPIRATION_ADDED_TIME = 1
2525
cls._USER_ID = Config.get_user_id()
26-
cls._API_CONTEXT = cls.get_api_context()
26+
cls._API_CONTEXT = cls._get_api_context()
2727

2828
def test_draft_share_invite_bank(self):
2929
"""

tests/model/generated/test_monetary_account_bank.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def setUpClass(cls):
2020
cls._FIELD_CURRENCY = 'EUR'
2121
cls._MONETARY_ACCOUNT_PREFIX = 'Python_test'
2222
cls._USER_ID = Config.get_user_id()
23-
cls._API_CONTEXT = cls.get_api_context()
23+
cls._API_CONTEXT = cls._get_api_context()
2424

2525
def test_create_new_monetary_account(self):
2626
"""

tests/model/generated/test_payment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setUpClass(cls):
2424
cls._COUNTER_PARTY_OTHER_USER = Config.get_pointer_counter_party_other()
2525
cls._COUNTER_PARTY_SAME_USER = Config.get_pointer_counter_party_self()
2626
cls._MONETARY_ACCOUNT_ID = Config.get_monetary_account_id_1()
27-
cls._API_CONTEXT = cls.get_api_context()
27+
cls._API_CONTEXT = cls._get_api_context()
2828

2929
def test_payment_to_other_user(self):
3030
"""

0 commit comments

Comments
 (0)