-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expand tests to include some flask/integration testing
- Loading branch information
Showing
14 changed files
with
132 additions
and
11 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
def is_dictionary_inside(d1, d2): | ||
return d1.items() <= d2.items() | ||
|
Binary file not shown.
Empty file.
47 changes: 47 additions & 0 deletions
47
022-burette/magnum_opus/tests/application/test_alembic_instruction_resource.py
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,47 @@ | ||
import pytest | ||
from magnumopus import create_app | ||
from .. import is_dictionary_inside | ||
from .test_substance_resource import create_substance_request | ||
|
||
def create_alembic_instruction_request(client, instruction_type, natures, action=None): | ||
data = { | ||
'instruction_type': instruction_type, | ||
'natures': ','.join(natures) | ||
} | ||
|
||
if action is not None: | ||
data['action'] = action | ||
|
||
return client.post('/alembic_instruction', data=data) | ||
|
||
def test_create_alembic_mix_instruction(client): | ||
create_substance_request(client, ['Mercury']) | ||
create_substance_request(client, ['Salt']) | ||
create_substance_request(client, ['Sulphur']) | ||
|
||
rv = create_alembic_instruction_request(client, 'mix', ['Mercury', 'Salt', 'Sulphur']) | ||
|
||
assert rv.status_code == 201 | ||
|
||
content = rv.get_json() | ||
|
||
assert is_dictionary_inside({ | ||
'nature': 'Gloop', | ||
'state': [], | ||
'is_philosophers_stone': False | ||
}, content) | ||
|
||
def test_create_alembic_process_instruction(client): | ||
create_substance_request(client, ['Mercury']) | ||
|
||
rv = create_alembic_instruction_request(client, 'process', ['Mercury'], 'cook') | ||
|
||
assert rv.status_code == 201 | ||
|
||
content = rv.get_json() | ||
|
||
assert is_dictionary_inside({ | ||
'nature': 'Mercury', | ||
'state': ['cooked'], | ||
'is_philosophers_stone': False | ||
}, content) |
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
022-burette/magnum_opus/tests/application/test_philosophers_stone.py
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,7 @@ | ||
import pytest | ||
from magnumopus import create_app | ||
from .. import is_dictionary_inside | ||
|
||
|
||
def test_create_philosophers_stone(client): | ||
pass |
50 changes: 50 additions & 0 deletions
50
022-burette/magnum_opus/tests/application/test_substance_resource.py
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,50 @@ | ||
import pytest | ||
from magnumopus import create_app | ||
from .. import is_dictionary_inside | ||
|
||
def create_substance_request(client, nature): | ||
return client.post('/substance', data={ | ||
'nature': nature | ||
}) | ||
|
||
def index_substances_request(client, nature): | ||
return client.get(f'/substance?nature={nature}') | ||
|
||
def test_create_substance(client): | ||
rv = create_substance_request(client, 'Sulphur') | ||
|
||
assert rv.status_code == 201 | ||
|
||
content = rv.get_json() | ||
|
||
assert type(content['id']) is int | ||
|
||
assert is_dictionary_inside({ | ||
'nature': 'Sulphur', | ||
'state': [], | ||
'is_philosophers_stone': False | ||
}, content) | ||
|
||
|
||
def test_get_substances(client): | ||
create_substance_request(client, 'Sulphur') | ||
|
||
rv = index_substances_request(client, 'Sulphur') | ||
|
||
assert rv.status_code == 200 | ||
|
||
content = rv.get_json() | ||
|
||
assert type(content) is list | ||
|
||
assert len(content) == 1 | ||
|
||
assert type(content[0]['id']) is int | ||
|
||
assert is_dictionary_inside({ | ||
'nature': 'Sulphur', | ||
'state': [], | ||
'is_philosophers_stone': False | ||
}, content[0]) | ||
|
||
# We also need non-happy paths! |
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