Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions tests/modules/test_browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def test_get_browse_results_with_no_filter_value():
def test_get_browse_results_with_invalid_page():
'''Should raise exception when invalid page parameter is provided'''

with raises(HttpException, match=r'page must be an integer'):
with raises(HttpException, match=r'page: value is not a valid integer'):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results(
FILTER_NAME,
Expand All @@ -407,7 +407,7 @@ def test_get_browse_results_with_invalid_page():
def test_get_browse_results_with_invalid_results_per_page():
'''Should raise exception when invalid results_per_page parameter is provided'''

with raises(HttpException, match=r'num_results_per_page must be an integer'):
with raises(HttpException, match=r'num_results_per_page: value is not a valid integer'):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results(
FILTER_NAME,
Expand All @@ -431,7 +431,7 @@ def test_get_browse_results_with_invalid_filters():
def test_get_browse_results_with_invalid_sort_by():
'''Should raise exception when invalid sort_by parameter is provided'''

with raises(HttpException, match=r'sort_by must be a string'):
with raises(HttpException, match=r'sort_by: str type expected'):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results(
FILTER_NAME,
Expand All @@ -443,7 +443,10 @@ def test_get_browse_results_with_invalid_sort_by():
def test_get_browse_results_with_invalid_sort_order():
'''Should raise exception when invalid sort_order parameter is provided'''

with raises(HttpException, match=r'Invalid value for parameter: "sort_order"'):
with raises(
HttpException,
match=r"sort_order: value is not a valid enumeration member; permitted: 'ascending', 'descending'"
):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results(
FILTER_NAME,
Expand Down Expand Up @@ -1091,7 +1094,7 @@ def test_get_browse_results_for_item_ids_with_invalid_item_ids():
def test_get_browse_results_for_item_ids_with_invalid_page():
'''Should raise exception when invalid page parameter is provided'''

with raises(HttpException, match=r'page must be an integer'):
with raises(HttpException, match=r'page: value is not a valid integer'):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results_for_item_ids(
IDS,
Expand All @@ -1102,7 +1105,7 @@ def test_get_browse_results_for_item_ids_with_invalid_page():
def test_get_browse_results_for_item_ids_with_invalid_results_per_page():
'''Should raise exception when invalid results_per_page parameter is provided'''

with raises(HttpException, match=r'num_results_per_page must be an integer'):
with raises(HttpException, match=r'num_results_per_page: value is not a valid integer'):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results_for_item_ids(
IDS,
Expand All @@ -1124,7 +1127,7 @@ def test_get_browse_results_for_item_ids_with_invalid_filters():
def test_get_browse_results_for_item_ids_with_invalid_sort_by():
'''Should raise exception when invalid sort_by parameter is provided'''

with raises(HttpException, match=r'sort_by must be a string'):
with raises(HttpException, match=r'sort_by: str type expected'):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results_for_item_ids(
IDS,
Expand All @@ -1135,7 +1138,10 @@ def test_get_browse_results_for_item_ids_with_invalid_sort_by():
def test_get_browse_results_for_item_ids_with_invalid_sort_order():
'''Should raise exception when invalid sort_order parameter is provided'''

with raises(HttpException, match=r'Invalid value for parameter: "sort_order"'):
with raises(
HttpException,
match=r"sort_order: value is not a valid enumeration member; permitted: 'ascending', 'descending'"
):
browse = ConstructorIO(VALID_OPTIONS).browse
browse.get_browse_results_for_item_ids(
IDS,
Expand Down
7 changes: 4 additions & 3 deletions tests/modules/test_catalog_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
from constructor_io.constructor_io import ConstructorIO
from constructor_io.helpers.exception import HttpException

TIMEOUT = 60
TEST_API_KEY = environ['TEST_CATALOG_API_KEY']
TEST_API_TOKEN = environ['TEST_API_TOKEN']
VALID_OPTIONS = { 'api_key': TEST_API_KEY, 'api_token': TEST_API_TOKEN }
SECTION = 'Products'
CATALOG_EXAMPLES_BASE_URL = 'https://raw.githubusercontent.com/Constructor-io/integration-examples/main/catalog/' #pylint: disable=line-too-long
ITEMS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}items.csv').content
VARIATIONS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}variations.csv').content
ITEM_GROUPS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}item_groups.csv').content
ITEMS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}items.csv', timeout=TIMEOUT).content
VARIATIONS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}variations.csv', timeout=TIMEOUT).content
ITEM_GROUPS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}item_groups.csv', timeout=TIMEOUT).content

@pytest.fixture(autouse=True)
def slow_down_tests():
Expand Down
3 changes: 2 additions & 1 deletion tests/modules/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from constructor_io.helpers.exception import (ConstructorException,
HttpException)

TIMEOUT = 60
TEST_API_KEY = environ['TEST_CATALOG_API_KEY']
TEST_API_TOKEN = environ['TEST_API_TOKEN']
VALID_OPTIONS = { 'api_key': TEST_API_KEY, 'api_token': TEST_API_TOKEN}
CATALOG_EXAMPLES_BASE_URL = 'https://raw.githubusercontent.com/Constructor-io/integration-examples/main/catalog/' #pylint: disable=line-too-long
ITEMS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}items.csv').content
ITEMS = requests.get(f'{CATALOG_EXAMPLES_BASE_URL}items.csv', timeout=TIMEOUT).content

#make a replace catalog request and get task_id to use in tests
catalog = ConstructorIO(VALID_OPTIONS).catalog
Expand Down