-
Notifications
You must be signed in to change notification settings - Fork 4
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
Oleg Kozlov
committed
Sep 8, 2018
1 parent
6f0a8e5
commit b1ffdfc
Showing
1 changed file
with
41 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import json | ||
from unittest import mock | ||
|
||
import vcr | ||
|
||
from pyswrve import ItemsApi | ||
|
||
|
||
class TestItemsApi: | ||
""" Class for testing ItemsApi methods. | ||
Before testing: | ||
1. Save `api_key` and `personal_key` to `$HOME/.pyswrve` | ||
2. Create and modify `tests/names.json` | ||
""" | ||
|
||
cassette_path = 'tests/vcr_cassettes/%s.yml' | ||
skip_lst = ['api_key', 'personal_key'] | ||
|
||
names_path = 'tests/names.json' | ||
with open(names_path) as jf: | ||
names_dct = json.load(jf) | ||
|
||
@vcr.use_cassette(cassette_path % 'item-lst', | ||
filter_query_parameters=skip_lst) | ||
def test_get_item_lst(self): | ||
api = ItemsApi() | ||
res = api.get_item_lst() | ||
assert isinstance(res, list) | ||
assert isinstance(res[0], dict) | ||
|
||
@mock.patch.dict(os.environ, names_dct['item']) | ||
@vcr.use_cassette(cassette_path % 'item-attrs', | ||
filter_query_parameters=skip_lst) | ||
def test_get_item_attrs(self): | ||
api = ItemsApi() | ||
uid = os.environ['uid'] | ||
res = api.get_item_attrs(uid) | ||
assert isinstance(res, dict) |