From 54aa8e61e127736ed94fd315c2db456df5639f71 Mon Sep 17 00:00:00 2001 From: Andres Aguilera Date: Thu, 22 Oct 2020 13:00:22 -0300 Subject: [PATCH] Increase coverage --- tests/test_flattend_spider.py | 3 +++ tests/test_util.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_flattend_spider.py b/tests/test_flattend_spider.py index d24c43e6..cb0f99f3 100644 --- a/tests/test_flattend_spider.py +++ b/tests/test_flattend_spider.py @@ -72,3 +72,6 @@ def test_extension_error(): 'file_name': 'file', 'url': 'http://example.com/example/file' } + + with pytest.raises(StopIteration): + next(generator) diff --git a/tests/test_util.py b/tests/test_util.py index 62c73437..2e09fb0b 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,6 +1,6 @@ import pytest -from kingfisher_scrapy.util import get_parameter_value, replace_parameters +from kingfisher_scrapy.util import components, get_parameter_value, replace_parameters @pytest.mark.parametrize('url,value,expected', [ @@ -20,3 +20,12 @@ def test_replace_parameters(url, value, expected): ]) def test_get_parameter_value(url, expected): assert get_parameter_value(url, 'page') == expected + + +@pytest.mark.parametrize('url,expected', [ + ('http://example.com/example/file.json', 'file'), + ('http://example.com/example/file.xlsx', 'file'), + ('http://example.com/example/file.csv', 'file'), +]) +def test_components(url, expected): + assert components(-1)(url) == expected