-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28b4cb7
commit 0a3282c
Showing
3 changed files
with
79 additions
and
5 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
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 |
---|---|---|
|
@@ -4,4 +4,20 @@ VALUES ( | |
'test', | ||
'$pbkdf2-sha256$29000$GiPk/H/P.R9jDOHcO6f0vg$d1hc5fqAKcY92Xpd9BccjpMzHSEVWKk4pIc4PN0HLCQ', | ||
'[email protected]' | ||
); | ||
); | ||
VALUES ( | ||
'testuser', | ||
'$pbkdf2-sha256$29000$GiPk/H/P.R9jDOHcO6f0vg$d1hc5fqAKcY92Xpd9BccjpMzHSEVWKk4pIc4PN0HLCQ', | ||
'[email protected]' | ||
); | ||
|
||
/* add a dummy gift list */ | ||
INSERT INTO gift_lists (id, user_id) | ||
VALUES (1, 2); | ||
INSERT INTO gift_lists (id, user_id) | ||
VALUES (2, 1); | ||
|
||
INSERT INTO gifts (id, item_id, list_id, available, purchased) | ||
VALUES (1, 1, 1, 1, 0); | ||
INSERT INTO gifts (id, item_id, list_id, available, purchased) | ||
VALUES (2, 2, 1, 2, 0); |
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,58 @@ | ||
import pytest | ||
import json | ||
|
||
|
||
def test_list_get(client, test_auth_headers): | ||
response = client.get('/api/v1/gifts/list', | ||
headers=test_auth_headers) | ||
assert response.status_code == 204 | ||
try: | ||
data = json.loads(response.get_data().decode()) | ||
assert data | ||
assert isinstance(data, list) | ||
except json.decoder.JSONDecodeError: | ||
pass | ||
|
||
|
||
@pytest.mark.skip('TODO') | ||
def test_list_gift_id_purchase_post(client, test_auth_headers): | ||
pass | ||
|
||
|
||
@pytest.mark.skip('TODO') | ||
def test_list_gift_id_delete(client, test_auth_headers): | ||
pass | ||
|
||
|
||
@pytest.mark.skip('TODO') | ||
def test_list_gift_id_get(client, test_auth_headers): | ||
pass | ||
|
||
|
||
@pytest.mark.skip('TODO') | ||
def test_list_add_post(client, test_auth_headers): | ||
pass | ||
|
||
|
||
def test_list_report_get(client, test_auth_headers): | ||
response = client.get('/api/v1/gifts/list/report', | ||
headers=test_auth_headers) | ||
assert response.status_code == 200 | ||
data = json.loads(response.get_data().decode()) | ||
assert data | ||
assert 'available' in data.keys() | ||
assert 'purchased' in data.keys() | ||
assert isinstance(data['available'], list) | ||
assert isinstance(data['purchased'], list) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
('endpoint', 'method', 'data', 'has_auth', 'code'), | ||
[('/api/v1/gifts/list', 'GET', None, True, 204)] | ||
) | ||
def test_protected_endpoint(client, test_auth_headers, | ||
endpoint, method, data, has_auth, code): | ||
request = getattr(client, method.lower()) | ||
response = request(endpoint, headers=test_auth_headers if has_auth else {}, | ||
data=data, mimetype='application/json') | ||
assert response.status_code == code |