Skip to content

Commit

Permalink
tests of items api
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Kozlov committed Sep 8, 2018
1 parent 6f0a8e5 commit b1ffdfc
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_items_api.py
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)

0 comments on commit b1ffdfc

Please sign in to comment.