forked from figo-connect/python-figo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean conftest, moved all catalog and header tests to own file
- Loading branch information
Berend Kapelle
committed
Feb 8, 2018
1 parent
ba72357
commit 0425c90
Showing
6 changed files
with
97 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ htmlcov/* | |
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
.eggs/ | ||
.pytest_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
CHANGES | ||
======= | ||
|
||
* making tests green | ||
* BAAS-31: Revert SSL | ||
* BAAS-31: Fix string | ||
* BAAS-31 Fix litreal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,12 @@ | |
PASSWORD = 'some_words' | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def figo_connection(): | ||
def new_user_id(): | ||
return "{0}[email protected]".format(uuid.uuid4()) | ||
|
||
|
||
|
||
def get_figo_connection(): | ||
return FigoConnection(CREDENTIALS['client_id'], | ||
CREDENTIALS['client_secret'], | ||
"https://127.0.0.1/", | ||
|
@@ -25,14 +29,11 @@ def figo_connection(): | |
|
||
|
||
@pytest.fixture(scope='module') | ||
def new_user_id(): | ||
return "{0}[email protected]".format(uuid.uuid4()) | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def figo_session(figo_connection, new_user_id): | ||
figo_connection.add_user("Test", new_user_id, PASSWORD) | ||
response = figo_connection.credential_login(new_user_id, PASSWORD) | ||
def figo_session(): | ||
user_id = new_user_id() | ||
figo_connection = get_figo_connection() | ||
figo_connection.add_user("Test", user_id, PASSWORD) | ||
response = figo_connection.credential_login(user_id, PASSWORD) | ||
|
||
scope = response['scope'] | ||
|
||
|
@@ -80,3 +81,16 @@ def giro_account(figo_session): | |
assert len(giro_accs) >= 1 | ||
|
||
yield giro_accs[0] | ||
|
||
@pytest.fixture(scope='module') | ||
def access_token(): | ||
user_id = new_user_id() | ||
figo_connection = get_figo_connection() | ||
figo_connection.add_user("Test", user_id, PASSWORD) | ||
response = figo_connection.credential_login(user_id, PASSWORD) | ||
access_token = response['access_token'] | ||
|
||
yield access_token | ||
|
||
session = FigoSession(access_token) | ||
session.remove_user() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import pytest | ||
|
||
from figo import FigoException | ||
from figo import FigoSession | ||
from figo.models import Service | ||
from figo.models import LoginSettings | ||
|
||
CREDENTIALS = ["figo", "figo"] | ||
BANK_CODE = "90090042" | ||
CLIENT_ERROR = 1000 | ||
|
||
@pytest.mark.parametrize('language', ['de', 'en']) | ||
def test_get_catalog_en(access_token, language): | ||
figo_session = FigoSession(access_token) | ||
figo_session.language = language | ||
catalog = figo_session.get_catalog() | ||
for bank in catalog['banks']: | ||
assert bank.language == language | ||
|
||
|
||
def test_get_catalog_invalid_language(access_token): | ||
figo_session = FigoSession(access_token) | ||
figo_session.language = 'xy' | ||
with pytest.raises(FigoException) as e: | ||
figo_session.get_catalog() | ||
assert e.value.code == CLIENT_ERROR | ||
|
||
|
||
def test_get_supported_payment_services(access_token): | ||
figo_session = FigoSession(access_token) | ||
services = figo_session.get_supported_payment_services("de") | ||
assert len(services) > 10 # this a changing value, this tests that at least some are returned | ||
assert isinstance(services[0], Service) | ||
|
||
|
||
def test_get_login_settings(access_token): | ||
figo_session = FigoSession(access_token) | ||
login_settings = figo_session.get_login_settings("de", "90090042") | ||
assert login_settings.advice | ||
assert login_settings.credentials | ||
|
||
|
||
# XXX(Valentin): Catalog needs `accounts=rw`, so it doesn't work with the demo session. | ||
# Sounds silly at first, but actually there is no point to view the catalog if | ||
# you can't add accounts. | ||
def test_get_catalog(access_token): | ||
figo_session = FigoSession(access_token) | ||
catalog = figo_session.get_catalog() | ||
assert len(catalog) == 2 | ||
|
||
|
||
def test_get_login_settings(access_token): | ||
figo_session = FigoSession(access_token) | ||
login_settings = figo_session.get_login_settings("de", BANK_CODE) | ||
assert isinstance(login_settings, LoginSettings) | ||
|
||
|
||
def test_set_unset_language(access_token): | ||
figo_session = FigoSession(access_token) | ||
assert figo_session.language is None | ||
figo_session.language = 'de' | ||
assert figo_session.language == 'de' | ||
figo_session.language = '' | ||
assert figo_session.language is None | ||
figo_session.language = 'de' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters