Skip to content

Commit

Permalink
fix: unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
alguadam committed Oct 8, 2023
1 parent 06fb9bf commit 994df3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def testing_client(scope='module'):
with app.app_context():
db.create_all()
account = Account('Test Account', '€')
account = Account('Test Account', '€', 'Spain')
db.session.add(account)
db.session.commit()

Expand Down
8 changes: 5 additions & 3 deletions tests/functional/test_routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from iebank_api import app
import pytest


def test_get_accounts(testing_client):
"""
GIVEN a Flask application
Expand All @@ -10,6 +11,7 @@ def test_get_accounts(testing_client):
response = testing_client.get('/accounts')
assert response.status_code == 200


def test_dummy_wrong_path():
"""
GIVEN a Flask application
Expand All @@ -20,13 +22,13 @@ def test_dummy_wrong_path():
response = client.get('/wrong_path')
assert response.status_code == 404


def test_create_account(testing_client):
"""
GIVEN a Flask application
WHEN the '/accounts' page is posted to (POST)
THEN check the response is valid
"""
response = testing_client.post('/accounts', json={'name': 'John Doe', 'currency': '€'})
response = testing_client.post(
'/accounts', json={'name': 'John Doe', 'currency': '€', 'country': 'Spain'})
assert response.status_code == 200


7 changes: 4 additions & 3 deletions tests/unit/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ def test_create_account():
"""
GIVEN a Account model
WHEN a new Account is created
THEN check the name, account_number, balance, currency, status and created_at fields are defined correctly
THEN check the name, account_number, balance, currency, country, status and created_at fields are defined correctly
"""
account = Account('John Doe', '€')
account = Account('John Doe', '€', 'Spain')
assert account.name == 'John Doe'
assert account.currency == '€'
assert account.account_number != None
assert account.balance == 0.0
assert account.status == 'Active'
assert account.status == 'Active'
assert account.country == 'Spain'

0 comments on commit 994df3a

Please sign in to comment.