test for search_keywords_and_filter_by_tags method (#254)

* new: test: search_keywords_and_filter_by_tags

* fix: test: set pytest version
This commit is contained in:
rachmadani haryono 2018-03-23 11:19:19 +08:00 committed by Arun Prakash Jana
parent 98d13207ec
commit 5c728030aa
2 changed files with 22 additions and 1 deletions

View File

@ -16,7 +16,7 @@ with open('README.md', encoding='utf-8') as f:
long_description = f.read()
tests_require = [
'pytest-cov', 'hypothesis>=3.7.0', 'pytest>=3.4.0', 'py>=1.5.0',
'pytest-cov', 'hypothesis>=3.7.0', 'pytest==3.4.2', 'py>=1.5.0',
'beautifulsoup4==4.6.0', 'flake8>=3.4.1', 'pylint>=1.7.2'
],

View File

@ -1309,6 +1309,27 @@ def test_load_firefox_database(firefox_db, add_pt):
assert call_args_list_dict == res_pickle
@pytest.mark.parametrize(
'keyword_results, stag_results, exp_res',
[
([], [], []),
(['item1'], ['item1', 'item2'], ['item1']),
(['item2'], ['item1'], []),
]
)
def test_search_keywords_and_filter_by_tags(keyword_results, stag_results, exp_res):
"""test method."""
# init
import buku
bdb = buku.BukuDb()
bdb.searchdb = mock.Mock(return_value=keyword_results)
bdb.search_by_tag = mock.Mock(return_value=stag_results)
# test
res = bdb.search_keywords_and_filter_by_tags(
mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock(), [])
assert exp_res == res
# Helper functions for testcases