Skip to content

Commit

Permalink
cleanup tests; fix README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dnl-blkv committed Aug 2, 2017
1 parent 6f1019f commit eeca577
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 14 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,36 @@ users = generated.User.list(api_context)

##### Example
See [`UserListExample.py`](./examples/user_list_example.py)

## Running Samples
In order to make the experience of getting into bunq Python SDK smoother, we
have bundled it with example use cases (located under `/examples`).

To run an example, please do the following:
1. In your IDE, open the example you are interested in and adjust the constants,
such as `_API_KEY` or `_USER_ID`, to hold your data.
2. In your terminal, go to the root of bunq SDK project:

```shell
$ cd /path/to/bunq/sdk/
```
3. In the terminal, run:

```shell
$ python3 run.py examples/<something_example.py>
```
Replace `<something_example.py>` with the name of the example you would like
to run. If you wish to run the example with python 2, also replace
`python3` with `python`.

In order for examples to run, you would need a valid context file (`bunq.conf`)
to be present in the bunq SDK project root directory. The file can either copied
from somewhere else (e.g. tests) or created by running the following command
in your bunq SDK project root directory:

```shell
$ python3 run.py examples/api_context_save_example.py
```

Please do not forget to set the `_API_KEY` constant in
`api_context_save_example.py` to your actual API key before running the sample!
4 changes: 2 additions & 2 deletions tests/assets/config.example.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"API_KEY": "<API KEY>",
"USER_ID": "xxxx",
"MA_ID": "xxxx",
"MA_ID2": "xxxx",
"MONETARY_ACCOUNT_ID": "xxxx",
"MONETARY_ACCOUNT_ID2": "xxxx",
"ipAddress": "<Ip address>",
"AttachmentPublicTest":{
"CONTENT_TYPE": "image/png",
Expand Down
2 changes: 1 addition & 1 deletion tests/bunq_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BunqSdkTestCase(unittest.TestCase):
_DEVICE_DESCRIPTION = 'Python test device'

@classmethod
def get_api_context(cls):
def _get_api_context(cls):
"""
Calls IsSessionActive to check if the session token is still active
and returns the ApiContext.
Expand Down
4 changes: 2 additions & 2 deletions tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Config:
_FIELD_ALIAS = "Alias"
_FIELD_TAB_USAGE = "TabUsageSingleTest"
_FIELD_CASH_REGISTER_ID = "CASH_REGISTER_ID"
_FIELD_MONETARY_ACCOUNT_ID_1 = "MA_ID"
_FIELD_MONETARY_ACCOUNT_ID_2 = "MA_ID2"
_FIELD_MONETARY_ACCOUNT_ID_1 = "MONETARY_ACCOUNT_ID"
_FIELD_MONETARY_ACCOUNT_ID_2 = "MONETARY_ACCOUNT_ID2"
_FIELD_USER_ID = "USER_ID"
_FIELD_API_KEY = "API_KEY"
_FIELD_ATTACHMENT_PUBLIC = "AttachmentPublicTest"
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_attachment_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUpClass(cls):
cls._CONTENT_TYPE = Config.get_attachment_content_type()
cls._ATTACHMENT_DESCRIPTION = Config.get_attachment_description()
cls._ATTACHMENT_PATH_IN = Config.get_attachment_path_in()
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_file_upload_and_retrieval(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setUpClass(cls):
cls._CONTENT_TYPE = Config.get_attachment_content_type()
cls._ATTACHMENT_DESCRIPTION = Config.get_attachment_description()
cls._ATTACHMENT_PATH_IN = Config.get_attachment_path_in()
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_avatar_creation(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_card_debit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUpClass(cls):
cls._SECOND_LINE_LENGTH_MAXIMUM = 20
cls._STRING_EMPTY = ''
cls._USER_ID = Config.get_user_id()
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_order_debit_card(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_draft_share_invite_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setUpClass(cls):
cls._WRITE_BYTES = 'wb'
cls._EXPIRATION_ADDED_TIME = 1
cls._USER_ID = Config.get_user_id()
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_draft_share_invite_bank(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_monetary_account_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUpClass(cls):
cls._FIELD_CURRENCY = 'EUR'
cls._MONETARY_ACCOUNT_PREFIX = 'Python_test'
cls._USER_ID = Config.get_user_id()
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_create_new_monetary_account(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setUpClass(cls):
cls._COUNTER_PARTY_OTHER_USER = Config.get_pointer_counter_party_other()
cls._COUNTER_PARTY_SAME_USER = Config.get_pointer_counter_party_self()
cls._MONETARY_ACCOUNT_ID = Config.get_monetary_account_id_1()
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_payment_to_other_user(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_request_inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setUpClass(cls):
cls._COUNTER_PARTY_SAME_USER = Config.get_pointer_counter_party_self()
cls._MONETARY_ACCOUNT_ID = Config.get_monetary_account_id_1()
cls._MONETARY_ACCOUNT_ID2 = Config.get_monetary_account_id_2()
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_sending_and_accepting_request(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setUpClass(cls):
cls._API_KEY = Config.get_api_key()
cls._BUNQ_CONFIG_FILE = "bunq-test.conf"
cls._DEVICE_DESCRIPTION = 'Python test device'
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_session_delete(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/model/generated/test_tab_usage_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setUpClass(cls):
cls._TAB_ITEM_FIELD_DESCRIPTION = 'Super expensive python tea'
cls._STATUS_WAITING = 'WAITING_FOR_PAYMENT'
cls._TAB_FIELD_DESCRIPTION = 'Pay the tab for Python test please.'
cls._API_CONTEXT = cls.get_api_context()
cls._API_CONTEXT = cls._get_api_context()

def test_create_and_update_tab(self):
"""
Expand Down

0 comments on commit eeca577

Please sign in to comment.