From 5b56baec9457c49a0fdffcb72e1a25761bede108 Mon Sep 17 00:00:00 2001 From: Ondrej Fiedler Date: Fri, 10 Jan 2025 16:54:58 +0100 Subject: [PATCH] Release: v5.0.0 - Support new Recommend Items to Item Segment endpoint - Series API improvements: - Add Series endpoint creates associated Item for the Series automatically (based on the cascadeCreate parameter) - Breaking change: Remove From Series no longer requires the time parameter - Removed deprecated Groups endpoints --- recombee_api_client/__init__.py | 1 + recombee_api_client/api_client.py | 2 +- recombee_api_client/api_requests/__init__.py | 7 +- .../api_requests/add_bookmark.py | 2 +- .../api_requests/add_cart_addition.py | 2 +- .../api_requests/add_detail_view.py | 2 +- recombee_api_client/api_requests/add_group.py | 33 --- recombee_api_client/api_requests/add_item.py | 2 +- .../api_requests/add_item_property.py | 2 +- .../api_requests/add_purchase.py | 2 +- .../api_requests/add_rating.py | 2 +- .../api_requests/add_series.py | 12 +- recombee_api_client/api_requests/add_user.py | 2 +- .../api_requests/add_user_property.py | 2 +- .../api_requests/delete_bookmark.py | 2 +- .../api_requests/delete_cart_addition.py | 2 +- .../api_requests/delete_detail_view.py | 2 +- .../api_requests/delete_group.py | 36 --- .../api_requests/delete_item.py | 2 +- .../api_requests/delete_more_items.py | 2 +- .../api_requests/delete_purchase.py | 2 +- .../api_requests/delete_rating.py | 2 +- .../api_requests/delete_series.py | 12 +- .../api_requests/delete_user.py | 2 +- .../api_requests/delete_view_portion.py | 2 +- .../api_requests/get_item_property_info.py | 2 +- .../api_requests/get_item_values.py | 2 +- .../api_requests/get_user_values.py | 2 +- .../api_requests/insert_to_group.py | 50 ---- .../api_requests/insert_to_series.py | 4 +- .../api_requests/list_group_items.py | 33 --- .../api_requests/list_groups.py | 28 -- .../recommend_item_segments_to_item.py | 4 +- ...recommend_item_segments_to_item_segment.py | 4 +- .../recommend_item_segments_to_user.py | 4 +- .../recommend_items_to_item_segment.py | 274 ++++++++++++++++++ .../api_requests/remove_from_group.py | 41 --- .../api_requests/remove_from_series.py | 12 +- .../api_requests/set_view_portion.py | 2 +- .../api_requests/update_more_items.py | 2 +- recombee_api_client/exceptions.py | 2 +- setup.py | 25 +- tests/__init__.py | 1 + tests/test.py | 14 +- tests/test_cases/__init__.py | 1 + tests/test_cases/add_entity.py | 9 +- tests/test_cases/add_interaction.py | 18 +- tests/test_cases/add_manual_reql_segment.py | 5 +- tests/test_cases/add_property.py | 9 +- tests/test_cases/add_rating.py | 20 +- tests/test_cases/add_search_synonym.py | 7 +- .../create_auto_reql_segmentation.py | 7 +- .../create_manual_reql_segmentation.py | 7 +- .../create_property_based_segmentation.py | 7 +- .../test_cases/delete_all_search_synonyms.py | 5 +- tests/test_cases/delete_entity.py | 11 +- tests/test_cases/delete_interaction.py | 7 +- .../test_cases/delete_manual_reql_segment.py | 5 +- tests/test_cases/delete_more_items.py | 5 +- tests/test_cases/delete_property.py | 11 +- tests/test_cases/delete_search_synonym.py | 7 +- tests/test_cases/delete_segmentation.py | 7 +- tests/test_cases/delete_view_portion.py | 7 +- tests/test_cases/get_property_info.py | 5 +- tests/test_cases/get_segmentation.py | 5 +- tests/test_cases/get_values.py | 5 +- tests/test_cases/insert_to_group.py | 36 --- tests/test_cases/insert_to_series.py | 7 +- .../test_cases/item_to_item_recommendation.py | 5 +- tests/test_cases/list_entities.py | 6 +- .../list_entities_with_properties.py | 8 +- tests/test_cases/list_item_interactions.py | 6 +- tests/test_cases/list_properties.py | 6 +- tests/test_cases/list_search_synonyms.py | 6 +- tests/test_cases/list_segmentations.py | 6 +- tests/test_cases/list_set_items.py | 6 +- tests/test_cases/list_user_interactions.py | 6 +- tests/test_cases/merge_users.py | 7 +- tests/test_cases/next_items_recommendation.py | 5 +- tests/test_cases/recombee_test.py | 4 +- .../recommend_item_segments_to_item.py | 7 +- .../recommend_item_segments_to_user.py | 7 +- ...egment.py => recommend_to_item_segment.py} | 9 +- tests/test_cases/recommendation.py | 5 +- tests/test_cases/remove_from_group.py | 28 -- tests/test_cases/remove_from_series.py | 20 +- tests/test_cases/search.py | 5 +- tests/test_cases/search_item_segments.py | 7 +- tests/test_cases/set_values.py | 7 +- tests/test_cases/set_view_portion.py | 20 +- tests/test_cases/test_add_group.py | 13 - tests/test_cases/test_add_series.py | 4 +- tests/test_cases/test_batch.py | 2 +- tests/test_cases/test_delete_group.py | 13 - tests/test_cases/test_delete_series.py | 4 +- tests/test_cases/test_insert_to_group.py | 13 - .../test_item_based_recommendation.py | 10 - tests/test_cases/test_list_group_items.py | 13 - tests/test_cases/test_list_groups.py | 13 - ...recommend_item_segments_to_item_segment.py | 4 +- .../test_recommend_items_to_item_segment.py | 13 + tests/test_cases/test_remove_from_group.py | 13 - tests/test_cases/test_remove_from_series.py | 4 +- .../update_auto_reql_segmentation.py | 5 +- .../test_cases/update_manual_reql_segment.py | 5 +- .../update_manual_reql_segmentation.py | 5 +- tests/test_cases/update_more_items.py | 5 +- .../update_property_based_segmentation.py | 5 +- 108 files changed, 608 insertions(+), 580 deletions(-) delete mode 100644 recombee_api_client/api_requests/add_group.py delete mode 100644 recombee_api_client/api_requests/delete_group.py delete mode 100644 recombee_api_client/api_requests/insert_to_group.py delete mode 100644 recombee_api_client/api_requests/list_group_items.py delete mode 100644 recombee_api_client/api_requests/list_groups.py create mode 100644 recombee_api_client/api_requests/recommend_items_to_item_segment.py delete mode 100644 recombee_api_client/api_requests/remove_from_group.py delete mode 100644 tests/test_cases/insert_to_group.py rename tests/test_cases/{recommend_item_segments_to_item_segment.py => recommend_to_item_segment.py} (80%) delete mode 100644 tests/test_cases/remove_from_group.py delete mode 100644 tests/test_cases/test_add_group.py delete mode 100644 tests/test_cases/test_delete_group.py delete mode 100644 tests/test_cases/test_insert_to_group.py delete mode 100644 tests/test_cases/test_item_based_recommendation.py delete mode 100644 tests/test_cases/test_list_group_items.py delete mode 100644 tests/test_cases/test_list_groups.py create mode 100644 tests/test_cases/test_recommend_items_to_item_segment.py delete mode 100644 tests/test_cases/test_remove_from_group.py diff --git a/recombee_api_client/__init__.py b/recombee_api_client/__init__.py index e69de29..8b13789 100644 --- a/recombee_api_client/__init__.py +++ b/recombee_api_client/__init__.py @@ -0,0 +1 @@ + diff --git a/recombee_api_client/api_client.py b/recombee_api_client/api_client.py index 4b6546c..3dcce97 100644 --- a/recombee_api_client/api_client.py +++ b/recombee_api_client/api_client.py @@ -94,7 +94,7 @@ def __get_base_uri(options: dict, region: str) -> str: @staticmethod def __get_http_headers(additional_headers: dict = None) -> dict: - headers = {'User-Agent': 'recombee-python-api-client/4.1.0'} + headers = {'User-Agent': 'recombee-python-api-client/5.0.0'} if additional_headers: headers.update(additional_headers) return headers diff --git a/recombee_api_client/api_requests/__init__.py b/recombee_api_client/api_requests/__init__.py index 09dff88..0bf1539 100644 --- a/recombee_api_client/api_requests/__init__.py +++ b/recombee_api_client/api_requests/__init__.py @@ -15,12 +15,6 @@ from recombee_api_client.api_requests.list_series_items import ListSeriesItems from recombee_api_client.api_requests.insert_to_series import InsertToSeries from recombee_api_client.api_requests.remove_from_series import RemoveFromSeries -from recombee_api_client.api_requests.add_group import AddGroup -from recombee_api_client.api_requests.delete_group import DeleteGroup -from recombee_api_client.api_requests.list_groups import ListGroups -from recombee_api_client.api_requests.list_group_items import ListGroupItems -from recombee_api_client.api_requests.insert_to_group import InsertToGroup -from recombee_api_client.api_requests.remove_from_group import RemoveFromGroup from recombee_api_client.api_requests.add_user import AddUser from recombee_api_client.api_requests.delete_user import DeleteUser from recombee_api_client.api_requests.set_user_values import SetUserValues @@ -63,6 +57,7 @@ from recombee_api_client.api_requests.recommend_item_segments_to_user import RecommendItemSegmentsToUser from recombee_api_client.api_requests.recommend_item_segments_to_item import RecommendItemSegmentsToItem from recombee_api_client.api_requests.recommend_item_segments_to_item_segment import RecommendItemSegmentsToItemSegment +from recombee_api_client.api_requests.recommend_items_to_item_segment import RecommendItemsToItemSegment from recombee_api_client.api_requests.search_items import SearchItems from recombee_api_client.api_requests.search_item_segments import SearchItemSegments from recombee_api_client.api_requests.add_search_synonym import AddSearchSynonym diff --git a/recombee_api_client/api_requests/add_bookmark.py b/recombee_api_client/api_requests/add_bookmark.py index 9e9c80e..5001d43 100644 --- a/recombee_api_client/api_requests/add_bookmark.py +++ b/recombee_api_client/api_requests/add_bookmark.py @@ -29,7 +29,7 @@ class AddBookmark(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT): - super().__init__(path="/bookmarks/", method='post', timeout=1000, ensure_https=False) + super().__init__(path="/bookmarks/", method='post', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/add_cart_addition.py b/recombee_api_client/api_requests/add_cart_addition.py index 9349101..932dd86 100644 --- a/recombee_api_client/api_requests/add_cart_addition.py +++ b/recombee_api_client/api_requests/add_cart_addition.py @@ -33,7 +33,7 @@ class AddCartAddition(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, amount: float = DEFAULT, price: float = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT): - super().__init__(path="/cartadditions/", method='post', timeout=1000, ensure_https=False) + super().__init__(path="/cartadditions/", method='post', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/add_detail_view.py b/recombee_api_client/api_requests/add_detail_view.py index 55115b3..0c0a9ca 100644 --- a/recombee_api_client/api_requests/add_detail_view.py +++ b/recombee_api_client/api_requests/add_detail_view.py @@ -31,7 +31,7 @@ class AddDetailView(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, duration: int = DEFAULT, cascade_create: bool = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT): - super().__init__(path="/detailviews/", method='post', timeout=1000, ensure_https=False) + super().__init__(path="/detailviews/", method='post', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/add_group.py b/recombee_api_client/api_requests/add_group.py deleted file mode 100644 index 32563ce..0000000 --- a/recombee_api_client/api_requests/add_group.py +++ /dev/null @@ -1,33 +0,0 @@ -from recombee_api_client.api_requests.request import Request -from typing import Union, List -import uuid - -DEFAULT = uuid.uuid4() - -class AddGroup(Request): - """ - Creates a new group in the database. - Required parameters: - - :param group_id: ID of the group to be created. - - - """ - - def __init__(self, group_id: str): - super().__init__(path="/groups/%s" % (group_id), method='put', timeout=1000, ensure_https=False) - self.group_id = group_id - - def get_body_parameters(self) -> dict: - """ - Values of body parameters as a dictionary (name of parameter: value of the parameter). - """ - p = dict() - return p - - def get_query_parameters(self) -> dict: - """ - Values of query parameters as a dictionary (name of parameter: value of the parameter). - """ - params = dict() - return params diff --git a/recombee_api_client/api_requests/add_item.py b/recombee_api_client/api_requests/add_item.py index 08ed674..dbc43a6 100644 --- a/recombee_api_client/api_requests/add_item.py +++ b/recombee_api_client/api_requests/add_item.py @@ -18,7 +18,7 @@ class AddItem(Request): """ def __init__(self, item_id: str): - super().__init__(path="/items/%s" % (item_id), method='put', timeout=1000, ensure_https=False) + super().__init__(path="/items/%s" % (item_id), method='put', timeout=3000, ensure_https=False) self.item_id = item_id def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/add_item_property.py b/recombee_api_client/api_requests/add_item_property.py index 8480204..1aa865e 100644 --- a/recombee_api_client/api_requests/add_item_property.py +++ b/recombee_api_client/api_requests/add_item_property.py @@ -6,7 +6,7 @@ class AddItemProperty(Request): """ - Adding an item property is somehow equivalent to adding a column to the table of items. The items may be characterized by various properties of different types. + Adding an item property is somewhat equivalent to adding a column to the table of items. The items may be characterized by various properties of different types. Required parameters: diff --git a/recombee_api_client/api_requests/add_purchase.py b/recombee_api_client/api_requests/add_purchase.py index 06f71cd..134c0c0 100644 --- a/recombee_api_client/api_requests/add_purchase.py +++ b/recombee_api_client/api_requests/add_purchase.py @@ -35,7 +35,7 @@ class AddPurchase(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, amount: float = DEFAULT, price: float = DEFAULT, profit: float = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT): - super().__init__(path="/purchases/", method='post', timeout=1000, ensure_https=False) + super().__init__(path="/purchases/", method='post', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/add_rating.py b/recombee_api_client/api_requests/add_rating.py index 4c7ab2a..b5e6a39 100644 --- a/recombee_api_client/api_requests/add_rating.py +++ b/recombee_api_client/api_requests/add_rating.py @@ -31,7 +31,7 @@ class AddRating(Request): """ def __init__(self, user_id: str, item_id: str, rating: float, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT): - super().__init__(path="/ratings/", method='post', timeout=1000, ensure_https=False) + super().__init__(path="/ratings/", method='post', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.rating = rating diff --git a/recombee_api_client/api_requests/add_series.py b/recombee_api_client/api_requests/add_series.py index dea76bf..4aba2f7 100644 --- a/recombee_api_client/api_requests/add_series.py +++ b/recombee_api_client/api_requests/add_series.py @@ -11,18 +11,26 @@ class AddSeries(Request): :param series_id: ID of the series to be created. + + Optional parameters: + + :param cascade_create: If set to `true`, the item will be created with the same ID as the series. Default is `true`. + """ - def __init__(self, series_id: str): - super().__init__(path="/series/%s" % (series_id), method='put', timeout=1000, ensure_https=False) + def __init__(self, series_id: str, cascade_create: bool = DEFAULT): + super().__init__(path="/series/%s" % (series_id), method='put', timeout=3000, ensure_https=False) self.series_id = series_id + self.cascade_create = cascade_create def get_body_parameters(self) -> dict: """ Values of body parameters as a dictionary (name of parameter: value of the parameter). """ p = dict() + if self.cascade_create is not DEFAULT: + p['cascadeCreate'] = self.cascade_create return p def get_query_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/add_user.py b/recombee_api_client/api_requests/add_user.py index f486499..a6e694e 100644 --- a/recombee_api_client/api_requests/add_user.py +++ b/recombee_api_client/api_requests/add_user.py @@ -16,7 +16,7 @@ class AddUser(Request): """ def __init__(self, user_id: str): - super().__init__(path="/users/%s" % (user_id), method='put', timeout=1000, ensure_https=False) + super().__init__(path="/users/%s" % (user_id), method='put', timeout=3000, ensure_https=False) self.user_id = user_id def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/add_user_property.py b/recombee_api_client/api_requests/add_user_property.py index 064712e..a3d6752 100644 --- a/recombee_api_client/api_requests/add_user_property.py +++ b/recombee_api_client/api_requests/add_user_property.py @@ -6,7 +6,7 @@ class AddUserProperty(Request): """ - Adding a user property is somehow equivalent to adding a column to the table of users. The users may be characterized by various properties of different types. + Adding a user property is somewhat equivalent to adding a column to the table of users. The users may be characterized by various properties of different types. Required parameters: diff --git a/recombee_api_client/api_requests/delete_bookmark.py b/recombee_api_client/api_requests/delete_bookmark.py index 3eeaf1b..8cb66ad 100644 --- a/recombee_api_client/api_requests/delete_bookmark.py +++ b/recombee_api_client/api_requests/delete_bookmark.py @@ -23,7 +23,7 @@ class DeleteBookmark(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT): - super().__init__(path="/bookmarks/", method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/bookmarks/", method='delete', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/delete_cart_addition.py b/recombee_api_client/api_requests/delete_cart_addition.py index 8305c2f..f9a95b5 100644 --- a/recombee_api_client/api_requests/delete_cart_addition.py +++ b/recombee_api_client/api_requests/delete_cart_addition.py @@ -23,7 +23,7 @@ class DeleteCartAddition(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT): - super().__init__(path="/cartadditions/", method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/cartadditions/", method='delete', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/delete_detail_view.py b/recombee_api_client/api_requests/delete_detail_view.py index 00a8adc..8cf6ff1 100644 --- a/recombee_api_client/api_requests/delete_detail_view.py +++ b/recombee_api_client/api_requests/delete_detail_view.py @@ -23,7 +23,7 @@ class DeleteDetailView(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT): - super().__init__(path="/detailviews/", method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/detailviews/", method='delete', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/delete_group.py b/recombee_api_client/api_requests/delete_group.py deleted file mode 100644 index 7845cb5..0000000 --- a/recombee_api_client/api_requests/delete_group.py +++ /dev/null @@ -1,36 +0,0 @@ -from recombee_api_client.api_requests.request import Request -from typing import Union, List -import uuid - -DEFAULT = uuid.uuid4() - -class DeleteGroup(Request): - """ - Deletes the group of the given `groupId` from the database. - - Deleting a group will only delete the assignment of items to it, not the items themselves! - - Required parameters: - - :param group_id: ID of the group to be deleted. - - - """ - - def __init__(self, group_id: str): - super().__init__(path="/groups/%s" % (group_id), method='delete', timeout=1000, ensure_https=False) - self.group_id = group_id - - def get_body_parameters(self) -> dict: - """ - Values of body parameters as a dictionary (name of parameter: value of the parameter). - """ - p = dict() - return p - - def get_query_parameters(self) -> dict: - """ - Values of query parameters as a dictionary (name of parameter: value of the parameter). - """ - params = dict() - return params diff --git a/recombee_api_client/api_requests/delete_item.py b/recombee_api_client/api_requests/delete_item.py index 45e36b6..3fe14eb 100644 --- a/recombee_api_client/api_requests/delete_item.py +++ b/recombee_api_client/api_requests/delete_item.py @@ -20,7 +20,7 @@ class DeleteItem(Request): """ def __init__(self, item_id: str): - super().__init__(path="/items/%s" % (item_id), method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/items/%s" % (item_id), method='delete', timeout=3000, ensure_https=False) self.item_id = item_id def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/delete_more_items.py b/recombee_api_client/api_requests/delete_more_items.py index c47ea1c..93904a7 100644 --- a/recombee_api_client/api_requests/delete_more_items.py +++ b/recombee_api_client/api_requests/delete_more_items.py @@ -17,7 +17,7 @@ class DeleteMoreItems(Request): """ def __init__(self, filter: str): - super().__init__(path="/more-items/", method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/more-items/", method='delete', timeout=100000, ensure_https=False) self.filter = filter def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/delete_purchase.py b/recombee_api_client/api_requests/delete_purchase.py index 4983311..ccca1be 100644 --- a/recombee_api_client/api_requests/delete_purchase.py +++ b/recombee_api_client/api_requests/delete_purchase.py @@ -23,7 +23,7 @@ class DeletePurchase(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT): - super().__init__(path="/purchases/", method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/purchases/", method='delete', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/delete_rating.py b/recombee_api_client/api_requests/delete_rating.py index e47e172..17d9a0e 100644 --- a/recombee_api_client/api_requests/delete_rating.py +++ b/recombee_api_client/api_requests/delete_rating.py @@ -23,7 +23,7 @@ class DeleteRating(Request): """ def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT): - super().__init__(path="/ratings/", method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/ratings/", method='delete', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.timestamp = timestamp diff --git a/recombee_api_client/api_requests/delete_series.py b/recombee_api_client/api_requests/delete_series.py index a3b41d2..7cd8bf9 100644 --- a/recombee_api_client/api_requests/delete_series.py +++ b/recombee_api_client/api_requests/delete_series.py @@ -14,18 +14,26 @@ class DeleteSeries(Request): :param series_id: ID of the series to be deleted. + + Optional parameters: + + :param cascade_delete: If set to `true`, item with the same ID as seriesId will be also deleted. Default is `false`. + """ - def __init__(self, series_id: str): - super().__init__(path="/series/%s" % (series_id), method='delete', timeout=1000, ensure_https=False) + def __init__(self, series_id: str, cascade_delete: bool = DEFAULT): + super().__init__(path="/series/%s" % (series_id), method='delete', timeout=3000, ensure_https=False) self.series_id = series_id + self.cascade_delete = cascade_delete def get_body_parameters(self) -> dict: """ Values of body parameters as a dictionary (name of parameter: value of the parameter). """ p = dict() + if self.cascade_delete is not DEFAULT: + p['cascadeDelete'] = self.cascade_delete return p def get_query_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/delete_user.py b/recombee_api_client/api_requests/delete_user.py index d6622b3..b73f66b 100644 --- a/recombee_api_client/api_requests/delete_user.py +++ b/recombee_api_client/api_requests/delete_user.py @@ -18,7 +18,7 @@ class DeleteUser(Request): """ def __init__(self, user_id: str): - super().__init__(path="/users/%s" % (user_id), method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/users/%s" % (user_id), method='delete', timeout=3000, ensure_https=False) self.user_id = user_id def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/delete_view_portion.py b/recombee_api_client/api_requests/delete_view_portion.py index fec3a6a..6944a7f 100644 --- a/recombee_api_client/api_requests/delete_view_portion.py +++ b/recombee_api_client/api_requests/delete_view_portion.py @@ -23,7 +23,7 @@ class DeleteViewPortion(Request): """ def __init__(self, user_id: str, item_id: str, session_id: str = DEFAULT): - super().__init__(path="/viewportions/", method='delete', timeout=1000, ensure_https=False) + super().__init__(path="/viewportions/", method='delete', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.session_id = session_id diff --git a/recombee_api_client/api_requests/get_item_property_info.py b/recombee_api_client/api_requests/get_item_property_info.py index 845d961..d298a2a 100644 --- a/recombee_api_client/api_requests/get_item_property_info.py +++ b/recombee_api_client/api_requests/get_item_property_info.py @@ -16,7 +16,7 @@ class GetItemPropertyInfo(Request): """ def __init__(self, property_name: str): - super().__init__(path="/items/properties/%s" % (property_name), method='get', timeout=1000, ensure_https=False) + super().__init__(path="/items/properties/%s" % (property_name), method='get', timeout=3000, ensure_https=False) self.property_name = property_name def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/get_item_values.py b/recombee_api_client/api_requests/get_item_values.py index 13041c8..a9abd30 100644 --- a/recombee_api_client/api_requests/get_item_values.py +++ b/recombee_api_client/api_requests/get_item_values.py @@ -17,7 +17,7 @@ class GetItemValues(Request): """ def __init__(self, item_id: str): - super().__init__(path="/items/%s" % (item_id), method='get', timeout=1000, ensure_https=False) + super().__init__(path="/items/%s" % (item_id), method='get', timeout=3000, ensure_https=False) self.item_id = item_id def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/get_user_values.py b/recombee_api_client/api_requests/get_user_values.py index b34d5ab..96232fd 100644 --- a/recombee_api_client/api_requests/get_user_values.py +++ b/recombee_api_client/api_requests/get_user_values.py @@ -17,7 +17,7 @@ class GetUserValues(Request): """ def __init__(self, user_id: str): - super().__init__(path="/users/%s" % (user_id), method='get', timeout=1000, ensure_https=False) + super().__init__(path="/users/%s" % (user_id), method='get', timeout=3000, ensure_https=False) self.user_id = user_id def get_body_parameters(self) -> dict: diff --git a/recombee_api_client/api_requests/insert_to_group.py b/recombee_api_client/api_requests/insert_to_group.py deleted file mode 100644 index 8c61206..0000000 --- a/recombee_api_client/api_requests/insert_to_group.py +++ /dev/null @@ -1,50 +0,0 @@ -from recombee_api_client.api_requests.request import Request -from typing import Union, List -import uuid - -DEFAULT = uuid.uuid4() - -class InsertToGroup(Request): - """ - Inserts an existing item/group into a group of the given `groupId`. - - Required parameters: - - :param group_id: ID of the group to be inserted into. - - :param item_type: `item` iff the regular item from the catalog is to be inserted, `group` iff group is inserted as the item. - - :param item_id: ID of the item iff `itemType` is `item`. ID of the group iff `itemType` is `group`. - - - Optional parameters: - - :param cascade_create: Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `groupId` and the `groupId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. Either items or group may be created if not present in the database. - - - """ - - def __init__(self, group_id: str, item_type: str, item_id: str, cascade_create: bool = DEFAULT): - super().__init__(path="/groups/%s/items/" % (group_id), method='post', timeout=1000, ensure_https=False) - self.group_id = group_id - self.item_type = item_type - self.item_id = item_id - self.cascade_create = cascade_create - - def get_body_parameters(self) -> dict: - """ - Values of body parameters as a dictionary (name of parameter: value of the parameter). - """ - p = dict() - p['itemType'] = self.item_type - p['itemId'] = self.item_id - if self.cascade_create is not DEFAULT: - p['cascadeCreate'] = self.cascade_create - return p - - def get_query_parameters(self) -> dict: - """ - Values of query parameters as a dictionary (name of parameter: value of the parameter). - """ - params = dict() - return params diff --git a/recombee_api_client/api_requests/insert_to_series.py b/recombee_api_client/api_requests/insert_to_series.py index 8f0c870..d265f38 100644 --- a/recombee_api_client/api_requests/insert_to_series.py +++ b/recombee_api_client/api_requests/insert_to_series.py @@ -21,13 +21,13 @@ class InsertToSeries(Request): Optional parameters: - :param cascade_create: Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. Either item or series may be created if not present in the database. + :param cascade_create: Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. In case of `item`, an item is created, in case of `series` a series + corresponding item with the same ID is created. """ def __init__(self, series_id: str, item_type: str, item_id: str, time: float, cascade_create: bool = DEFAULT): - super().__init__(path="/series/%s/items/" % (series_id), method='post', timeout=1000, ensure_https=False) + super().__init__(path="/series/%s/items/" % (series_id), method='post', timeout=3000, ensure_https=False) self.series_id = series_id self.item_type = item_type self.item_id = item_id diff --git a/recombee_api_client/api_requests/list_group_items.py b/recombee_api_client/api_requests/list_group_items.py deleted file mode 100644 index c01f87d..0000000 --- a/recombee_api_client/api_requests/list_group_items.py +++ /dev/null @@ -1,33 +0,0 @@ -from recombee_api_client.api_requests.request import Request -from typing import Union, List -import uuid - -DEFAULT = uuid.uuid4() - -class ListGroupItems(Request): - """ - List all the items present in the given group. - Required parameters: - - :param group_id: ID of the group whose items are to be listed. - - - """ - - def __init__(self, group_id: str): - super().__init__(path="/groups/%s/items/" % (group_id), method='get', timeout=100000, ensure_https=False) - self.group_id = group_id - - def get_body_parameters(self) -> dict: - """ - Values of body parameters as a dictionary (name of parameter: value of the parameter). - """ - p = dict() - return p - - def get_query_parameters(self) -> dict: - """ - Values of query parameters as a dictionary (name of parameter: value of the parameter). - """ - params = dict() - return params diff --git a/recombee_api_client/api_requests/list_groups.py b/recombee_api_client/api_requests/list_groups.py deleted file mode 100644 index ba52f9a..0000000 --- a/recombee_api_client/api_requests/list_groups.py +++ /dev/null @@ -1,28 +0,0 @@ -from recombee_api_client.api_requests.request import Request -from typing import Union, List -import uuid - -DEFAULT = uuid.uuid4() - -class ListGroups(Request): - """ - Gets the list of all the groups currently present in the database. - - """ - - def __init__(self): - super().__init__(path="/groups/list/", method='get', timeout=100000, ensure_https=False) - - def get_body_parameters(self) -> dict: - """ - Values of body parameters as a dictionary (name of parameter: value of the parameter). - """ - p = dict() - return p - - def get_query_parameters(self) -> dict: - """ - Values of query parameters as a dictionary (name of parameter: value of the parameter). - """ - params = dict() - return params diff --git a/recombee_api_client/api_requests/recommend_item_segments_to_item.py b/recombee_api_client/api_requests/recommend_item_segments_to_item.py index 55ff90a..15e1ab5 100644 --- a/recombee_api_client/api_requests/recommend_item_segments_to_item.py +++ b/recombee_api_client/api_requests/recommend_item_segments_to_item.py @@ -6,7 +6,7 @@ class RecommendItemSegmentsToItem(Request): """ - Recommends Segments from a Segmentation that are the most relevant to a particular item. + Recommends Segments from a [Segmentation](https://docs.recombee.com/segmentations.html) that are the most relevant to a particular item. Based on the used Segmentation, this endpoint can be used for example for: @@ -15,7 +15,7 @@ class RecommendItemSegmentsToItem(Request): - Recommending the related brands - Recommending the related artists - You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint. + You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint. The returned segments are sorted by relevance (first segment being the most relevant). diff --git a/recombee_api_client/api_requests/recommend_item_segments_to_item_segment.py b/recombee_api_client/api_requests/recommend_item_segments_to_item_segment.py index 3be31cd..9ab7269 100644 --- a/recombee_api_client/api_requests/recommend_item_segments_to_item_segment.py +++ b/recombee_api_client/api_requests/recommend_item_segments_to_item_segment.py @@ -6,7 +6,7 @@ class RecommendItemSegmentsToItemSegment(Request): """ - Recommends Segments from a result Segmentation that are the most relevant to a particular Segment from a context Segmentation. + Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations.html) that are the most relevant to a particular Segment from a context Segmentation. Based on the used Segmentations, this endpoint can be used for example for: @@ -14,7 +14,7 @@ class RecommendItemSegmentsToItemSegment(Request): - Recommending the related brands to particular category - Recommending the related artists to a particular genre (assuming songs are the Items) - You need to set the used context and result Segmentation the Admin UI in the Scenario settings prior to using this endpoint. + You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint. The returned segments are sorted by relevance (first segment being the most relevant). diff --git a/recombee_api_client/api_requests/recommend_item_segments_to_user.py b/recombee_api_client/api_requests/recommend_item_segments_to_user.py index 6c71d33..58f66db 100644 --- a/recombee_api_client/api_requests/recommend_item_segments_to_user.py +++ b/recombee_api_client/api_requests/recommend_item_segments_to_user.py @@ -6,7 +6,7 @@ class RecommendItemSegmentsToUser(Request): """ - Recommends the top Segments from a Segmentation for a particular user, based on the user's past interactions. + Recommends the top Segments from a [Segmentation](https://docs.recombee.com/segmentations.html) for a particular user, based on the user's past interactions. Based on the used Segmentation, this endpoint can be used for example for: @@ -15,7 +15,7 @@ class RecommendItemSegmentsToUser(Request): - Recommending the top brands for the user - Recommending the top artists for the user - You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint. + You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint. The returned segments are sorted by relevance (first segment being the most relevant). diff --git a/recombee_api_client/api_requests/recommend_items_to_item_segment.py b/recombee_api_client/api_requests/recommend_items_to_item_segment.py new file mode 100644 index 0000000..eb568db --- /dev/null +++ b/recombee_api_client/api_requests/recommend_items_to_item_segment.py @@ -0,0 +1,274 @@ +from recombee_api_client.api_requests.request import Request +from typing import Union, List +import uuid + +DEFAULT = uuid.uuid4() + +class RecommendItemsToItemSegment(Request): + """ + Recommends Items that are the most relevant to a particular Segment from a context [Segmentation](https://docs.recombee.com/segmentations.html). + + Based on the used Segmentation, this endpoint can be used for example for: + + - Recommending articles related to a particular topic + - Recommending songs belonging to a particular genre + - Recommending products produced by a particular brand + + You need to set the used context Segmentation in the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint. + + The returned items are sorted by relevance (the first item being the most relevant). + + It is also possible to use the POST HTTP method (for example, in the case of a very long ReQL filter) — query parameters then become body parameters. + + Required parameters: + + :param context_segment_id: ID of the segment from `contextSegmentationId` for which the recommendations are to be generated. + + :param target_user_id: ID of the user who will see the recommendations. + + + Specifying the *targetUserId* is beneficial because: + + + * It makes the recommendations personalized + + * Allows the calculation of Actions and Conversions + + in the graphical user interface, + + as Recombee can pair the user who got recommendations + + and who afterward viewed/purchased an item. + + + If you insist on not specifying the user, pass `null` + + (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*. + + Do not create some special dummy user for getting recommendations, + + as it could mislead the recommendation models, + + and result in wrong recommendations. + + + For anonymous/unregistered users, it is possible to use, for example, their session ID. + + + :param count: Number of items to be recommended (N for the top-N recommendation). + + + Optional parameters: + + :param scenario: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + + + You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + + + The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. + + + :param cascade_create: If an item of the given *itemId* or user of the given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows, for example, rotations in the following recommendations for the user of the given *targetUserId*, as the user will be already known to the system. + + :param return_properties: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user. + + + Example response: + + ``` + + E{lb} + + "recommId": "0c6189e7-dc1a-429a-b613-192696309361", + + "recomms": + + [ + + E{lb} + + "id": "tv-178", + + "values": E{lb} + + "description": "4K TV with 3D feature", + + "categories": ["Electronics", "Televisions"], + + "price": 342, + + "url": "myshop.com/tv-178" + E{rb} + E{rb}, + + E{lb} + + "id": "mixer-42", + + "values": E{lb} + + "description": "Stainless Steel Mixer", + + "categories": ["Home & Kitchen"], + + "price": 39, + + "url": "myshop.com/mixer-42" + E{rb} + E{rb} + + ], + + "numberNextRecommsCalls": 0 + E{rb} + + ``` + + + :param included_properties: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + + + Example response for `includedProperties=description,price`: + + ``` + + E{lb} + + "recommId": "6842c725-a79f-4537-a02c-f34d668a3f80", + + "recomms": + + [ + + E{lb} + + "id": "tv-178", + + "values": E{lb} + + "description": "4K TV with 3D feature", + + "price": 342 + E{rb} + E{rb}, + + E{lb} + + "id": "mixer-42", + + "values": E{lb} + + "description": "Stainless Steel Mixer", + + "price": 39 + E{rb} + E{rb} + + ], + + "numberNextRecommsCalls": 0 + E{rb} + + ``` + + + :param filter: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter recommended items based on the values of their attributes. + + + Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + + + :param booster: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes. + + + Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + + + :param logic: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + + See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. + + + The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. + + + Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + + + :param min_relevance: **Expert option** If the *targetUserId* is provided: Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than *count* items when there is not enough data to fulfill it. + + + :param rotation_rate: **Expert option** If the *targetUserId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example, `rotationRate=0.2` for only slight rotation of recommended items. + + + :param rotation_time: **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long it takes for an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. + + + :param expert_settings: Dictionary of custom options. + + + :param return_ab_group: If there is a custom AB-testing running, return the name of the group to which the request belongs. + + + + """ + + def __init__(self, context_segment_id: str, target_user_id: str, count: int, scenario: str = DEFAULT, cascade_create: bool = DEFAULT, return_properties: bool = DEFAULT, included_properties: list = DEFAULT, filter: str = DEFAULT, booster: str = DEFAULT, logic: Union[str, dict] = DEFAULT, min_relevance: str = DEFAULT, rotation_rate: float = DEFAULT, rotation_time: float = DEFAULT, expert_settings: dict = DEFAULT, return_ab_group: bool = DEFAULT): + super().__init__(path="/recomms/item-segments/items/", method='post', timeout=3000, ensure_https=False) + self.context_segment_id = context_segment_id + self.target_user_id = target_user_id + self.count = count + self.scenario = scenario + self.cascade_create = cascade_create + self.return_properties = return_properties + self.included_properties = included_properties + self.filter = filter + self.booster = booster + self.logic = logic + self.min_relevance = min_relevance + self.rotation_rate = rotation_rate + self.rotation_time = rotation_time + self.expert_settings = expert_settings + self.return_ab_group = return_ab_group + + def get_body_parameters(self) -> dict: + """ + Values of body parameters as a dictionary (name of parameter: value of the parameter). + """ + p = dict() + p['contextSegmentId'] = self.context_segment_id + p['targetUserId'] = self.target_user_id + p['count'] = self.count + if self.scenario is not DEFAULT: + p['scenario'] = self.scenario + if self.cascade_create is not DEFAULT: + p['cascadeCreate'] = self.cascade_create + if self.return_properties is not DEFAULT: + p['returnProperties'] = self.return_properties + if self.included_properties is not DEFAULT: + p['includedProperties'] = self.included_properties + if self.filter is not DEFAULT: + p['filter'] = self.filter + if self.booster is not DEFAULT: + p['booster'] = self.booster + if self.logic is not DEFAULT: + p['logic'] = self.logic + if self.min_relevance is not DEFAULT: + p['minRelevance'] = self.min_relevance + if self.rotation_rate is not DEFAULT: + p['rotationRate'] = self.rotation_rate + if self.rotation_time is not DEFAULT: + p['rotationTime'] = self.rotation_time + if self.expert_settings is not DEFAULT: + p['expertSettings'] = self.expert_settings + if self.return_ab_group is not DEFAULT: + p['returnAbGroup'] = self.return_ab_group + return p + + def get_query_parameters(self) -> dict: + """ + Values of query parameters as a dictionary (name of parameter: value of the parameter). + """ + params = dict() + return params diff --git a/recombee_api_client/api_requests/remove_from_group.py b/recombee_api_client/api_requests/remove_from_group.py deleted file mode 100644 index 0d2af8a..0000000 --- a/recombee_api_client/api_requests/remove_from_group.py +++ /dev/null @@ -1,41 +0,0 @@ -from recombee_api_client.api_requests.request import Request -from typing import Union, List -import uuid - -DEFAULT = uuid.uuid4() - -class RemoveFromGroup(Request): - """ - Removes an existing group item from the group. - Required parameters: - - :param group_id: ID of the group from which a group item is to be removed. - - :param item_type: Type of the item to be removed. - - :param item_id: ID of the item iff `itemType` is `item`. ID of the group iff `itemType` is `group`. - - - """ - - def __init__(self, group_id: str, item_type: str, item_id: str): - super().__init__(path="/groups/%s/items/" % (group_id), method='delete', timeout=1000, ensure_https=False) - self.group_id = group_id - self.item_type = item_type - self.item_id = item_id - - def get_body_parameters(self) -> dict: - """ - Values of body parameters as a dictionary (name of parameter: value of the parameter). - """ - p = dict() - return p - - def get_query_parameters(self) -> dict: - """ - Values of query parameters as a dictionary (name of parameter: value of the parameter). - """ - params = dict() - params['itemType'] = self.item_type - params['itemId'] = self.item_id - return params diff --git a/recombee_api_client/api_requests/remove_from_series.py b/recombee_api_client/api_requests/remove_from_series.py index ab9fb29..babbb54 100644 --- a/recombee_api_client/api_requests/remove_from_series.py +++ b/recombee_api_client/api_requests/remove_from_series.py @@ -15,23 +15,22 @@ class RemoveFromSeries(Request): :param item_id: ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`. - :param time: Time index of the item to be removed. - """ - def __init__(self, series_id: str, item_type: str, item_id: str, time: float): - super().__init__(path="/series/%s/items/" % (series_id), method='delete', timeout=1000, ensure_https=False) + def __init__(self, series_id: str, item_type: str, item_id: str): + super().__init__(path="/series/%s/items/" % (series_id), method='delete', timeout=3000, ensure_https=False) self.series_id = series_id self.item_type = item_type self.item_id = item_id - self.time = time def get_body_parameters(self) -> dict: """ Values of body parameters as a dictionary (name of parameter: value of the parameter). """ p = dict() + p['itemType'] = self.item_type + p['itemId'] = self.item_id return p def get_query_parameters(self) -> dict: @@ -39,7 +38,4 @@ def get_query_parameters(self) -> dict: Values of query parameters as a dictionary (name of parameter: value of the parameter). """ params = dict() - params['itemType'] = self.item_type - params['itemId'] = self.item_id - params['time'] = self.time return params diff --git a/recombee_api_client/api_requests/set_view_portion.py b/recombee_api_client/api_requests/set_view_portion.py index ba9fce7..f3544d2 100644 --- a/recombee_api_client/api_requests/set_view_portion.py +++ b/recombee_api_client/api_requests/set_view_portion.py @@ -34,7 +34,7 @@ class SetViewPortion(Request): """ def __init__(self, user_id: str, item_id: str, portion: float, session_id: str = DEFAULT, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT): - super().__init__(path="/viewportions/", method='post', timeout=1000, ensure_https=False) + super().__init__(path="/viewportions/", method='post', timeout=3000, ensure_https=False) self.user_id = user_id self.item_id = item_id self.portion = portion diff --git a/recombee_api_client/api_requests/update_more_items.py b/recombee_api_client/api_requests/update_more_items.py index b7d1316..62a0018 100644 --- a/recombee_api_client/api_requests/update_more_items.py +++ b/recombee_api_client/api_requests/update_more_items.py @@ -27,7 +27,7 @@ class UpdateMoreItems(Request): """ def __init__(self, filter: str, changes: dict): - super().__init__(path="/more-items/", method='post', timeout=1000, ensure_https=False) + super().__init__(path="/more-items/", method='post', timeout=100000, ensure_https=False) self.filter = filter self.changes = changes diff --git a/recombee_api_client/exceptions.py b/recombee_api_client/exceptions.py index a71072e..697b234 100644 --- a/recombee_api_client/exceptions.py +++ b/recombee_api_client/exceptions.py @@ -29,4 +29,4 @@ def __init__(self, request: Request): super(ApiTimeoutException, self).__init__("ApiTimeout: client did not get response within %s ms" % request.timeout) - self.request = request \ No newline at end of file + self.request = request diff --git a/setup.py b/setup.py index db3c102..5b8c328 100644 --- a/setup.py +++ b/setup.py @@ -11,19 +11,16 @@ setup( name='recombee-api-client', - version='4.1.0', + version='5.0.0', description='Client for Recombee recommendation API', long_description=long_description, - # The project's main homepage. url='https://github.com/Recombee/python-api-client', - # Author details author='Recombee', author_email='ondrej.fiedler@recombee.com', - # Choose your license license='MIT', classifiers=[ @@ -31,34 +28,32 @@ 'Intended Audience :: Developers', 'Topic :: Scientific/Engineering', - 'Topic :: Software Development', + 'Topic :: Software Development :: Libraries :: Python Modules', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ], - keywords='recommendation engine as a service', + keywords='recommendation engine, recommender engine as a service, search, personalization, recombee, API client, machine learning', + packages=find_packages(exclude=['contrib', 'docs', 'tests*']), - packages=find_packages(exclude=['contrib', 'docs', 'tests']), - - - install_requires=['requests'], + install_requires=[ + 'requests>=2.20.0', + ], - python_requires='>=3.4', + python_requires='>=3.6', extras_require={}, package_data={}, - data_files=[], - entry_points={}, ) diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..8b13789 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/test.py b/tests/test.py index 42f93e7..5e90626 100644 --- a/tests/test.py +++ b/tests/test.py @@ -48,18 +48,6 @@ suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(InsertToSeriesTestCase)) from tests.test_cases.test_remove_from_series import RemoveFromSeriesTestCase suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(RemoveFromSeriesTestCase)) - from tests.test_cases.test_add_group import AddGroupTestCase - suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(AddGroupTestCase)) - from tests.test_cases.test_delete_group import DeleteGroupTestCase - suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(DeleteGroupTestCase)) - from tests.test_cases.test_list_groups import ListGroupsTestCase - suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(ListGroupsTestCase)) - from tests.test_cases.test_list_group_items import ListGroupItemsTestCase - suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(ListGroupItemsTestCase)) - from tests.test_cases.test_insert_to_group import InsertToGroupTestCase - suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(InsertToGroupTestCase)) - from tests.test_cases.test_remove_from_group import RemoveFromGroupTestCase - suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(RemoveFromGroupTestCase)) from tests.test_cases.test_add_user import AddUserTestCase suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(AddUserTestCase)) from tests.test_cases.test_delete_user import DeleteUserTestCase @@ -144,6 +132,8 @@ suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(RecommendItemSegmentsToItemTestCase)) from tests.test_cases.test_recommend_item_segments_to_item_segment import RecommendItemSegmentsToItemSegmentTestCase suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(RecommendItemSegmentsToItemSegmentTestCase)) + from tests.test_cases.test_recommend_items_to_item_segment import RecommendItemsToItemSegmentTestCase + suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(RecommendItemsToItemSegmentTestCase)) from tests.test_cases.test_search_items import SearchItemsTestCase suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(SearchItemsTestCase)) from tests.test_cases.test_search_item_segments import SearchItemSegmentsTestCase diff --git a/tests/test_cases/__init__.py b/tests/test_cases/__init__.py index e69de29..8b13789 100644 --- a/tests/test_cases/__init__.py +++ b/tests/test_cases/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/test_cases/add_entity.py b/tests/test_cases/add_entity.py index 2d8b7d2..01ba988 100644 --- a/tests/test_cases/add_entity.py +++ b/tests/test_cases/add_entity.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class AddEntityTest(RecombeeTest): +class AddEntityTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,item_id): pass @@ -22,7 +25,7 @@ def test_add_entity(self): req = self.create_request('***not_valid$$$') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) # it 'really stores entity to the system' @@ -30,7 +33,7 @@ def test_add_entity(self): resp = self.client.send(req) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/add_interaction.py b/tests/test_cases/add_interaction.py index 10bf3a5..108f820 100644 --- a/tests/test_cases/add_interaction.py +++ b/tests/test_cases/add_interaction.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class AddInteractionTest(RecombeeTest): +class AddInteractionTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,user_id,item_id,timestamp=None,cascade_create=None,recomm_id=None,additional_data=None): pass @@ -28,29 +31,22 @@ def test_add_interaction(self): req = self.create_request('entity_id', 'nonex_id') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) # it 'fails with nonexisting user id' req = self.create_request('nonex_id', 'entity_id') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) - # it 'fails with invalid time' - req = self.create_request('entity_id', 'entity_id', timestamp=-15) - try: - self.client.send(req) - self.assertFail() - except ResponseException as ex: - self.assertEqual(ex.status_code, 400) # it 'really stores interaction to the system' req = self.create_request('u_id2', 'i_id2', cascade_create=True, timestamp=5) resp = self.client.send(req) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/add_manual_reql_segment.py b/tests/test_cases/add_manual_reql_segment.py index 970dfc8..cdea4d3 100644 --- a/tests/test_cases/add_manual_reql_segment.py +++ b/tests/test_cases/add_manual_reql_segment.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class AddManualReqlSegmentTest(RecombeeTest): +class AddManualReqlSegmentTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,segment_id,filter,title=None): pass diff --git a/tests/test_cases/add_property.py b/tests/test_cases/add_property.py index b446cbb..6df4438 100644 --- a/tests/test_cases/add_property.py +++ b/tests/test_cases/add_property.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class AddPropertyTest(RecombeeTest): +class AddPropertyTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,property_name,type): pass @@ -24,7 +27,7 @@ def test_add_property(self): req = self.create_request('prop', 'integer') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) # it 'really stores property to the system' @@ -32,7 +35,7 @@ def test_add_property(self): resp = self.client.send(req) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/add_rating.py b/tests/test_cases/add_rating.py index fce5817..7545300 100644 --- a/tests/test_cases/add_rating.py +++ b/tests/test_cases/add_rating.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class AddRatingTest(RecombeeTest): +class AddRatingTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,user_id,item_id,rating,timestamp=None,cascade_create=None,recomm_id=None,additional_data=None): pass @@ -25,28 +28,21 @@ def test_add_rating(self): req = self.create_request('entity_id', 'nonex_id', -1) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) # it 'fails with nonexisting user id' req = self.create_request('nonex_id', 'entity_id', 0.5) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) - # it 'fails with invalid time' - req = self.create_request('entity_id', 'entity_id', 0, timestamp=-15) - try: - self.client.send(req) - self.assertFail() - except ResponseException as ex: - self.assertEqual(ex.status_code, 400) # it 'fails with invalid rating' req = self.create_request('entity_id', 'entity_id', -2) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) # it 'really stores interaction to the system' @@ -54,7 +50,7 @@ def test_add_rating(self): resp = self.client.send(req) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/add_search_synonym.py b/tests/test_cases/add_search_synonym.py index 5ccab7c..83bf33a 100644 --- a/tests/test_cases/add_search_synonym.py +++ b/tests/test_cases/add_search_synonym.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class AddSearchSynonymTest(RecombeeTest): +class AddSearchSynonymTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,term,synonym,one_way=None): pass @@ -23,7 +26,7 @@ def test_add_search_synonym(self): req = self.create_request('sci-fi', 'science fiction', one_way=True) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/create_auto_reql_segmentation.py b/tests/test_cases/create_auto_reql_segmentation.py index 1d650cf..870eccc 100644 --- a/tests/test_cases/create_auto_reql_segmentation.py +++ b/tests/test_cases/create_auto_reql_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class CreateAutoReqlSegmentationTest(RecombeeTest): +class CreateAutoReqlSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,source_type,expression,title=None,description=None): pass @@ -21,7 +24,7 @@ def test_create_auto_reql_segmentation(self): req = self.create_request('seg1', 'items', '{\'str_property\'}', title='Test Segmentation', description='For test purposes') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/create_manual_reql_segmentation.py b/tests/test_cases/create_manual_reql_segmentation.py index cd2543f..b64dcdf 100644 --- a/tests/test_cases/create_manual_reql_segmentation.py +++ b/tests/test_cases/create_manual_reql_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class CreateManualReqlSegmentationTest(RecombeeTest): +class CreateManualReqlSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,source_type,title=None,description=None): pass @@ -21,7 +24,7 @@ def test_create_manual_reql_segmentation(self): req = self.create_request('seg1', 'items', title='Test Segmentation', description='For test purposes') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/create_property_based_segmentation.py b/tests/test_cases/create_property_based_segmentation.py index 1d1a11e..7961981 100644 --- a/tests/test_cases/create_property_based_segmentation.py +++ b/tests/test_cases/create_property_based_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class CreatePropertyBasedSegmentationTest(RecombeeTest): +class CreatePropertyBasedSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,source_type,property_name,title=None,description=None): pass @@ -21,7 +24,7 @@ def test_create_property_based_segmentation(self): req = self.create_request('seg1', 'items', 'str_property', title='Test Segmentation', description='For test purposes') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/delete_all_search_synonyms.py b/tests/test_cases/delete_all_search_synonyms.py index 1134e1a..d469ecd 100644 --- a/tests/test_cases/delete_all_search_synonyms.py +++ b/tests/test_cases/delete_all_search_synonyms.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteAllSearchSynonymsTest(RecombeeTest): +class DeleteAllSearchSynonymsTest(RecombeeTest, ABC): + @abstractmethod def create_request(self): pass diff --git a/tests/test_cases/delete_entity.py b/tests/test_cases/delete_entity.py index f0a3455..dbc6353 100644 --- a/tests/test_cases/delete_entity.py +++ b/tests/test_cases/delete_entity.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteEntityTest(RecombeeTest): +class DeleteEntityTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,item_id): pass @@ -20,21 +23,21 @@ def test_delete_entity(self): resp = self.client.send(req) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) # it 'fails with invalid entity id' req = self.create_request('***not_valid$$$') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) # it 'fails with non-existing entity' req = self.create_request('valid_id') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/delete_interaction.py b/tests/test_cases/delete_interaction.py index b04e0dd..93a78a4 100644 --- a/tests/test_cases/delete_interaction.py +++ b/tests/test_cases/delete_interaction.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteInteractionTest(InteractionsTest): +class DeleteInteractionTest(InteractionsTest, ABC): + @abstractmethod def create_request(self,user_id,item_id,timestamp=None): pass @@ -21,7 +24,7 @@ def test_delete_interaction(self): req = self.create_request('user', 'item') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/delete_manual_reql_segment.py b/tests/test_cases/delete_manual_reql_segment.py index aa9e804..5c4c931 100644 --- a/tests/test_cases/delete_manual_reql_segment.py +++ b/tests/test_cases/delete_manual_reql_segment.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteManualReqlSegmentTest(RecombeeTest): +class DeleteManualReqlSegmentTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,segment_id): pass diff --git a/tests/test_cases/delete_more_items.py b/tests/test_cases/delete_more_items.py index 48a4cad..f4c8d31 100644 --- a/tests/test_cases/delete_more_items.py +++ b/tests/test_cases/delete_more_items.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteMoreItemsTest(RecombeeTest): +class DeleteMoreItemsTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,filter): pass diff --git a/tests/test_cases/delete_property.py b/tests/test_cases/delete_property.py index 118878e..ba0d313 100644 --- a/tests/test_cases/delete_property.py +++ b/tests/test_cases/delete_property.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeletePropertyTest(RecombeeTest): +class DeletePropertyTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,property_name): pass @@ -20,21 +23,21 @@ def test_delete_property(self): resp = self.client.send(req) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) # it 'fails with invalid property' req = self.create_request('***not_valid$$$') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) # it 'fails with non-existing property' req = self.create_request('not_existing') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/delete_search_synonym.py b/tests/test_cases/delete_search_synonym.py index ea83575..0e1756b 100644 --- a/tests/test_cases/delete_search_synonym.py +++ b/tests/test_cases/delete_search_synonym.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteSearchSynonymTest(RecombeeTest): +class DeleteSearchSynonymTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,id): pass @@ -23,7 +26,7 @@ def test_delete_search_synonym(self): req = self.create_request('a968271b-d666-4dfb-8a30-f459e564ba7b') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/delete_segmentation.py b/tests/test_cases/delete_segmentation.py index f4d6c3f..d03f263 100644 --- a/tests/test_cases/delete_segmentation.py +++ b/tests/test_cases/delete_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteSegmentationTest(RecombeeTest): +class DeleteSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id): pass @@ -23,7 +26,7 @@ def test_delete_segmentation(self): req = self.create_request('seg1') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/delete_view_portion.py b/tests/test_cases/delete_view_portion.py index 1f252cb..eec05c3 100644 --- a/tests/test_cases/delete_view_portion.py +++ b/tests/test_cases/delete_view_portion.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class DeleteViewPortionTest(InteractionsTest): +class DeleteViewPortionTest(InteractionsTest, ABC): + @abstractmethod def create_request(self,user_id,item_id,session_id=None): pass @@ -21,7 +24,7 @@ def test_delete_view_portion(self): req = self.create_request('user', 'item') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/get_property_info.py b/tests/test_cases/get_property_info.py index a2ca2d7..9454c3d 100644 --- a/tests/test_cases/get_property_info.py +++ b/tests/test_cases/get_property_info.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class GetPropertyInfoTest(RecombeeTest): +class GetPropertyInfoTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,property_name): pass diff --git a/tests/test_cases/get_segmentation.py b/tests/test_cases/get_segmentation.py index c5232e0..6a32e5d 100644 --- a/tests/test_cases/get_segmentation.py +++ b/tests/test_cases/get_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class GetSegmentationTest(RecombeeTest): +class GetSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id): pass diff --git a/tests/test_cases/get_values.py b/tests/test_cases/get_values.py index d131167..0c059cf 100644 --- a/tests/test_cases/get_values.py +++ b/tests/test_cases/get_values.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class GetValuesTest(RecombeeTest): +class GetValuesTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,item_id): pass diff --git a/tests/test_cases/insert_to_group.py b/tests/test_cases/insert_to_group.py deleted file mode 100644 index 63c5cc0..0000000 --- a/tests/test_cases/insert_to_group.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest -from recombee_api_client.exceptions import ResponseException -from recombee_api_client.api_requests import * - -class InsertToGroupTest(RecombeeTest): - - def create_request(self,group_id,item_type,item_id,cascade_create=None): - pass - - def test_insert_to_group(self): - - # it 'does not fail when inserting existing item into existing set' - req = AddItem('new_item') - resp = self.client.send(req) - req = self.create_request('entity_id', 'item', 'new_item') - resp = self.client.send(req) - # it 'does not fail when cascadeCreate is used' - req = self.create_request('new_set', 'item', 'new_item2', cascade_create=True) - resp = self.client.send(req) - # it 'really inserts item to the set' - req = AddItem('new_item3') - resp = self.client.send(req) - req = self.create_request('entity_id', 'item', 'new_item3') - resp = self.client.send(req) - try: - self.client.send(req) - self.assertFail() - except ResponseException as ex: - self.assertEqual(ex.status_code, 409) - diff --git a/tests/test_cases/insert_to_series.py b/tests/test_cases/insert_to_series.py index 8422a9b..a01b225 100644 --- a/tests/test_cases/insert_to_series.py +++ b/tests/test_cases/insert_to_series.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class InsertToSeriesTest(RecombeeTest): +class InsertToSeriesTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,series_id,item_type,item_id,time,cascade_create=None): pass @@ -30,7 +33,7 @@ def test_insert_to_series(self): resp = self.client.send(req) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 409) diff --git a/tests/test_cases/item_to_item_recommendation.py b/tests/test_cases/item_to_item_recommendation.py index 76c12ce..6b136a7 100644 --- a/tests/test_cases/item_to_item_recommendation.py +++ b/tests/test_cases/item_to_item_recommendation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ItemToItemRecommendationTest(RecommendationsTest): +class ItemToItemRecommendationTest(RecommendationsTest, ABC): + @abstractmethod def create_request(self,item_id,target_user_id,count,scenario=None,cascade_create=None,return_properties=None,included_properties=None,filter=None,booster=None,logic=None,user_impact=None,diversity=None,min_relevance=None,rotation_rate=None,rotation_time=None,expert_settings=None,return_ab_group=None): pass diff --git a/tests/test_cases/list_entities.py b/tests/test_cases/list_entities.py index 2abea73..531ea2c 100644 --- a/tests/test_cases/list_entities.py +++ b/tests/test_cases/list_entities.py @@ -4,17 +4,21 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListEntitiesTest(RecombeeTest): +class ListEntitiesTest(RecombeeTest, ABC): + @abstractmethod def create_request(self): pass def test_list_entities(self): + time.sleep(10) # it 'lists entities' req = self.create_request() resp = self.client.send(req) diff --git a/tests/test_cases/list_entities_with_properties.py b/tests/test_cases/list_entities_with_properties.py index 223e121..fe42a0e 100644 --- a/tests/test_cases/list_entities_with_properties.py +++ b/tests/test_cases/list_entities_with_properties.py @@ -4,23 +4,27 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListEntitiesWithPropertiesTest(RecombeeTest): +class ListEntitiesWithPropertiesTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,filter=None,count=None,offset=None,return_properties=None,included_properties=None): pass def test_list_entities_with_properties(self): + time.sleep(10) # it 'lists entities' req = self.create_request() resp = self.client.send(req) self.assertEqual(resp, ['entity_id']) # it 'return properties' - req = self.create_request() + req = self.create_request(return_properties=True) resp = self.client.send(req) self.assertEqual(len(resp), 1) diff --git a/tests/test_cases/list_item_interactions.py b/tests/test_cases/list_item_interactions.py index 997832c..57fed50 100644 --- a/tests/test_cases/list_item_interactions.py +++ b/tests/test_cases/list_item_interactions.py @@ -4,17 +4,21 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListItemInteractionsTest(InteractionsTest): +class ListItemInteractionsTest(InteractionsTest, ABC): + @abstractmethod def create_request(self,item_id): pass def test_list_item_interactions(self): + time.sleep(10) # it 'lists interactions' req = self.create_request('item') resp = self.client.send(req) diff --git a/tests/test_cases/list_properties.py b/tests/test_cases/list_properties.py index 58cd613..b40a324 100644 --- a/tests/test_cases/list_properties.py +++ b/tests/test_cases/list_properties.py @@ -4,17 +4,21 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListPropertiesTest(RecombeeTest): +class ListPropertiesTest(RecombeeTest, ABC): + @abstractmethod def create_request(self): pass def test_list_properties(self): + time.sleep(10) # it 'lists properties' req = self.create_request() resp = self.client.send(req) diff --git a/tests/test_cases/list_search_synonyms.py b/tests/test_cases/list_search_synonyms.py index e93be2b..1c5e352 100644 --- a/tests/test_cases/list_search_synonyms.py +++ b/tests/test_cases/list_search_synonyms.py @@ -4,17 +4,21 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListSearchSynonymsTest(RecombeeTest): +class ListSearchSynonymsTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,count=None,offset=None): pass def test_list_search_synonyms(self): + time.sleep(10) # it 'lists search synonyms' req = AddSearchSynonym('sci-fi', 'science fiction') resp = self.client.send(req) diff --git a/tests/test_cases/list_segmentations.py b/tests/test_cases/list_segmentations.py index 12f5996..eaa6095 100644 --- a/tests/test_cases/list_segmentations.py +++ b/tests/test_cases/list_segmentations.py @@ -4,17 +4,21 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListSegmentationsTest(RecombeeTest): +class ListSegmentationsTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,source_type): pass def test_list_segmentations(self): + time.sleep(10) # it 'lists existing segmentations' req = CreatePropertyBasedSegmentation('seg1', 'items', 'str_property') resp = self.client.send(req) diff --git a/tests/test_cases/list_set_items.py b/tests/test_cases/list_set_items.py index 4b8005e..4c3cf7c 100644 --- a/tests/test_cases/list_set_items.py +++ b/tests/test_cases/list_set_items.py @@ -4,17 +4,21 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListSetItemsTest(RecombeeTest): +class ListSetItemsTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,series_id): pass def test_list_set_items(self): + time.sleep(10) # it 'lists set items' req = self.create_request('entity_id') resp = self.client.send(req) diff --git a/tests/test_cases/list_user_interactions.py b/tests/test_cases/list_user_interactions.py index 0a07064..3438878 100644 --- a/tests/test_cases/list_user_interactions.py +++ b/tests/test_cases/list_user_interactions.py @@ -4,17 +4,21 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class ListUserInteractionsTest(InteractionsTest): +class ListUserInteractionsTest(InteractionsTest, ABC): + @abstractmethod def create_request(self,user_id): pass def test_list_user_interactions(self): + time.sleep(10) # it 'lists user interactions' req = self.create_request('user') resp = self.client.send(req) diff --git a/tests/test_cases/merge_users.py b/tests/test_cases/merge_users.py index 07c667d..97e1288 100644 --- a/tests/test_cases/merge_users.py +++ b/tests/test_cases/merge_users.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class MergeUsersTest(RecombeeTest): +class MergeUsersTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,target_user_id,source_user_id,cascade_create=None): pass @@ -24,7 +27,7 @@ def test_merge_users(self): req = self.create_request('nonex_id', 'entity_id') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/next_items_recommendation.py b/tests/test_cases/next_items_recommendation.py index 85591aa..96be66e 100644 --- a/tests/test_cases/next_items_recommendation.py +++ b/tests/test_cases/next_items_recommendation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class NextItemsRecommendationTest(RecommendationsTest): +class NextItemsRecommendationTest(RecommendationsTest, ABC): + @abstractmethod def create_request(self,recomm_id,count): pass diff --git a/tests/test_cases/recombee_test.py b/tests/test_cases/recombee_test.py index 9aab328..b028854 100644 --- a/tests/test_cases/recombee_test.py +++ b/tests/test_cases/recombee_test.py @@ -46,8 +46,6 @@ def setUp(self): AddItem('entity_id'), AddUser('entity_id'), AddSeries('entity_id'), - AddGroup('entity_id'), - InsertToGroup('entity_id', 'item', 'entity_id'), InsertToSeries('entity_id', 'item', 'entity_id', 1), AddItemProperty('int_property', 'int'), AddItemProperty('str_property', 'string'), @@ -101,4 +99,4 @@ def setUp(self): self.client.send(Batch([AddUser(u) for u in my_users])) self.client.send(Batch([AddItemProperty('answer', 'int'), AddItemProperty('id2', 'string'), AddItemProperty('empty', 'string')])) self.client.send(Batch([SetItemValues(item_id, {'answer': 42, 'id2': item_id, '!cascadeCreate': True}) for item_id in my_items])) - self.client.send(Batch([AddPurchase(p['userId'], p['itemId']) for p in my_purchases ])) \ No newline at end of file + self.client.send(Batch([AddPurchase(p['userId'], p['itemId']) for p in my_purchases ])) diff --git a/tests/test_cases/recommend_item_segments_to_item.py b/tests/test_cases/recommend_item_segments_to_item.py index ea11413..77c175b 100644 --- a/tests/test_cases/recommend_item_segments_to_item.py +++ b/tests/test_cases/recommend_item_segments_to_item.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class RecommendItemSegmentsToItemTest(RecombeeTest): +class RecommendItemSegmentsToItemTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,item_id,target_user_id,count,scenario=None,cascade_create=None,filter=None,booster=None,logic=None,expert_settings=None,return_ab_group=None): pass @@ -19,7 +22,7 @@ def test_recommend_item_segments_to_item(self): req = self.create_request('entity_id', 'entity_id', 5, scenario='scenario1', cascade_create=True) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) diff --git a/tests/test_cases/recommend_item_segments_to_user.py b/tests/test_cases/recommend_item_segments_to_user.py index 0e7ced3..be94610 100644 --- a/tests/test_cases/recommend_item_segments_to_user.py +++ b/tests/test_cases/recommend_item_segments_to_user.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class RecommendItemSegmentsToUserTest(RecombeeTest): +class RecommendItemSegmentsToUserTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,user_id,count,scenario=None,cascade_create=None,filter=None,booster=None,logic=None,expert_settings=None,return_ab_group=None): pass @@ -19,7 +22,7 @@ def test_recommend_item_segments_to_user(self): req = self.create_request('entity_id', 5, scenario='scenario1', cascade_create=True) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) diff --git a/tests/test_cases/recommend_item_segments_to_item_segment.py b/tests/test_cases/recommend_to_item_segment.py similarity index 80% rename from tests/test_cases/recommend_item_segments_to_item_segment.py rename to tests/test_cases/recommend_to_item_segment.py index 553dc85..f155db1 100644 --- a/tests/test_cases/recommend_item_segments_to_item_segment.py +++ b/tests/test_cases/recommend_to_item_segment.py @@ -4,22 +4,25 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class RecommendItemSegmentsToItemSegmentTest(RecombeeTest): +class RecommendToItemSegmentTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,context_segment_id,target_user_id,count,scenario=None,cascade_create=None,filter=None,booster=None,logic=None,expert_settings=None,return_ab_group=None): pass - def test_recommend_item_segments_to_item_segment(self): + def test_recommend_to_item_segment(self): # it 'rejects request to scenario which is not set up' req = self.create_request('segment_id', 'entity_id', 5, scenario='scenario1', cascade_create=True) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) diff --git a/tests/test_cases/recommendation.py b/tests/test_cases/recommendation.py index 4550bbe..739114e 100644 --- a/tests/test_cases/recommendation.py +++ b/tests/test_cases/recommendation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class RecommendationTest(RecommendationsTest): +class RecommendationTest(RecommendationsTest, ABC): + @abstractmethod def create_request(self,user_id,count,scenario=None,cascade_create=None,return_properties=None,included_properties=None,filter=None,booster=None,logic=None,diversity=None,expert_settings=None,return_ab_group=None): pass diff --git a/tests/test_cases/remove_from_group.py b/tests/test_cases/remove_from_group.py deleted file mode 100644 index 7592064..0000000 --- a/tests/test_cases/remove_from_group.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest -from recombee_api_client.exceptions import ResponseException -from recombee_api_client.api_requests import * - -class RemoveFromGroupTest(RecombeeTest): - - def create_request(self,group_id,item_type,item_id): - pass - - def test_remove_from_group(self): - - # it 'does not fail when removing item that is contained in the set' - req = self.create_request('entity_id', 'item', 'entity_id') - resp = self.client.send(req) - # it 'fails when removing item that is not contained in the set' - req = self.create_request('entity_id', 'item', 'not_contained') - try: - self.client.send(req) - self.assertFail() - except ResponseException as ex: - self.assertEqual(ex.status_code, 404) - diff --git a/tests/test_cases/remove_from_series.py b/tests/test_cases/remove_from_series.py index 12e564e..5249c22 100644 --- a/tests/test_cases/remove_from_series.py +++ b/tests/test_cases/remove_from_series.py @@ -4,32 +4,28 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class RemoveFromSeriesTest(RecombeeTest): +class RemoveFromSeriesTest(RecombeeTest, ABC): - def create_request(self,series_id,item_type,item_id,time): + @abstractmethod + def create_request(self,series_id,item_type,item_id): pass def test_remove_from_series(self): - # it 'fails when removing item which have different time' - req = self.create_request('entity_id', 'item', 'entity_id', 0) - try: - self.client.send(req) - self.assertFail() - except ResponseException as ex: - self.assertEqual(ex.status_code, 404) # it 'does not fail when removing item that is contained in the set' - req = self.create_request('entity_id', 'item', 'entity_id', 1) + req = self.create_request('entity_id', 'item', 'entity_id') resp = self.client.send(req) # it 'fails when removing item that is not contained in the set' - req = self.create_request('entity_id', 'item', 'not_contained', 1) + req = self.create_request('entity_id', 'item', 'not_contained') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/search.py b/tests/test_cases/search.py index 9ff73d9..64fb8a8 100644 --- a/tests/test_cases/search.py +++ b/tests/test_cases/search.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class SearchTest(RecommendationsTest): +class SearchTest(RecommendationsTest, ABC): + @abstractmethod def create_request(self,user_id,search_query,count,scenario=None,cascade_create=None,return_properties=None,included_properties=None,filter=None,booster=None,logic=None,expert_settings=None,return_ab_group=None): pass diff --git a/tests/test_cases/search_item_segments.py b/tests/test_cases/search_item_segments.py index 5241b1d..be26931 100644 --- a/tests/test_cases/search_item_segments.py +++ b/tests/test_cases/search_item_segments.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class SearchItemSegmentsTest(RecombeeTest): +class SearchItemSegmentsTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,user_id,search_query,count,scenario=None,cascade_create=None,filter=None,booster=None,logic=None,expert_settings=None,return_ab_group=None): pass @@ -19,7 +22,7 @@ def test_search_item_segments(self): req = self.create_request('entity_id', 'query', 5, scenario='scenario1', cascade_create=True) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) diff --git a/tests/test_cases/set_values.py b/tests/test_cases/set_values.py index 3db115b..75efabd 100644 --- a/tests/test_cases/set_values.py +++ b/tests/test_cases/set_values.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class SetValuesTest(RecombeeTest): +class SetValuesTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,item_id,values,cascade_create=None): pass @@ -34,7 +37,7 @@ def test_set_values(self): req = self.create_request('nonexisting', {'int_property': 5}) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) diff --git a/tests/test_cases/set_view_portion.py b/tests/test_cases/set_view_portion.py index c6ed2dc..356db73 100644 --- a/tests/test_cases/set_view_portion.py +++ b/tests/test_cases/set_view_portion.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class SetViewPortionTest(RecombeeTest): +class SetViewPortionTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,user_id,item_id,portion,session_id=None,timestamp=None,cascade_create=None,recomm_id=None,additional_data=None): pass @@ -25,35 +28,28 @@ def test_set_view_portion(self): req = self.create_request('entity_id', 'nonex_id', 1) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) # it 'fails with nonexisting user id' req = self.create_request('nonex_id', 'entity_id', 0.5) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 404) - # it 'fails with invalid time' - req = self.create_request('entity_id', 'entity_id', 0, timestamp=-15) - try: - self.client.send(req) - self.assertFail() - except ResponseException as ex: - self.assertEqual(ex.status_code, 400) # it 'fails with invalid portion' req = self.create_request('entity_id', 'entity_id', -2) try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) # it 'fails with invalid sessionId' req = self.create_request('entity_id', 'entity_id', 0.7, session_id='a****') try: self.client.send(req) - self.assertFail() + self.fail() except ResponseException as ex: self.assertEqual(ex.status_code, 400) diff --git a/tests/test_cases/test_add_group.py b/tests/test_cases/test_add_group.py deleted file mode 100644 index 4fcaf65..0000000 --- a/tests/test_cases/test_add_group.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.add_entity import AddEntityTest -from recombee_api_client.api_requests import * - -class AddGroupTestCase(AddEntityTest): - - def create_request(self, group_id): - return AddGroup(group_id) diff --git a/tests/test_cases/test_add_series.py b/tests/test_cases/test_add_series.py index 9ae3344..0ce665f 100644 --- a/tests/test_cases/test_add_series.py +++ b/tests/test_cases/test_add_series.py @@ -9,5 +9,5 @@ class AddSeriesTestCase(AddEntityTest): - def create_request(self, series_id): - return AddSeries(series_id) + def create_request(self, series_id, cascade_create=None): + return AddSeries(series_id, cascade_create=cascade_create) diff --git a/tests/test_cases/test_batch.py b/tests/test_cases/test_batch.py index 9f31e8c..ef97543 100644 --- a/tests/test_cases/test_batch.py +++ b/tests/test_cases/test_batch.py @@ -35,7 +35,7 @@ def test_batch(self): self.assertEqual(sorted(resp[5]['json']), ['entity_id', 'item1', 'item2']) self.assertEqual(resp[6]['json'], ['item2']) self.assertEqual(resp[8]['json'], []) - self.assertEqual(resp[12]['json'], ['item2']) + self.assertEqual(resp[12]['json']['recomms'], ['item2']) def test_large_batch(self): NUM = 23578 diff --git a/tests/test_cases/test_delete_group.py b/tests/test_cases/test_delete_group.py deleted file mode 100644 index bbd3bac..0000000 --- a/tests/test_cases/test_delete_group.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.delete_entity import DeleteEntityTest -from recombee_api_client.api_requests import * - -class DeleteGroupTestCase(DeleteEntityTest): - - def create_request(self, group_id): - return DeleteGroup(group_id) diff --git a/tests/test_cases/test_delete_series.py b/tests/test_cases/test_delete_series.py index ea64a7f..8b473a6 100644 --- a/tests/test_cases/test_delete_series.py +++ b/tests/test_cases/test_delete_series.py @@ -9,5 +9,5 @@ class DeleteSeriesTestCase(DeleteEntityTest): - def create_request(self, series_id): - return DeleteSeries(series_id) + def create_request(self, series_id, cascade_delete=None): + return DeleteSeries(series_id, cascade_delete=cascade_delete) diff --git a/tests/test_cases/test_insert_to_group.py b/tests/test_cases/test_insert_to_group.py deleted file mode 100644 index 88fa97b..0000000 --- a/tests/test_cases/test_insert_to_group.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.insert_to_group import InsertToGroupTest -from recombee_api_client.api_requests import * - -class InsertToGroupTestCase(InsertToGroupTest): - - def create_request(self, group_id, item_type, item_id, cascade_create=None): - return InsertToGroup(group_id, item_type, item_id, cascade_create=cascade_create) diff --git a/tests/test_cases/test_item_based_recommendation.py b/tests/test_cases/test_item_based_recommendation.py deleted file mode 100644 index 04fcdf5..0000000 --- a/tests/test_cases/test_item_based_recommendation.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from tests.test_cases.recommendation import RecommendationTest -from recombee_api_client.api_requests import * - -class ItemBasedRecommendationTestCase (RecommendationTest): - - def create_request(self, user_id, count, filter=None, booster=None, allow_nonexistent=None, cascade_create=None, scenario=None, return_properties=None, included_properties=None, diversity=None, min_relevance=None, rotation_rate=None, rotation_time=None): - return ItemBasedRecommendation(user_id, count, target_user_id='entity_id', filter=filter, booster=booster, allow_nonexistent=allow_nonexistent, cascade_create=cascade_create, scenario=scenario, return_properties=return_properties, included_properties=included_properties, diversity=diversity, min_relevance=min_relevance, rotation_rate=rotation_rate, rotation_time=rotation_time) diff --git a/tests/test_cases/test_list_group_items.py b/tests/test_cases/test_list_group_items.py deleted file mode 100644 index 3d93731..0000000 --- a/tests/test_cases/test_list_group_items.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.list_set_items import ListSetItemsTest -from recombee_api_client.api_requests import * - -class ListGroupItemsTestCase(ListSetItemsTest): - - def create_request(self, group_id): - return ListGroupItems(group_id) diff --git a/tests/test_cases/test_list_groups.py b/tests/test_cases/test_list_groups.py deleted file mode 100644 index 7d2c610..0000000 --- a/tests/test_cases/test_list_groups.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.list_entities import ListEntitiesTest -from recombee_api_client.api_requests import * - -class ListGroupsTestCase(ListEntitiesTest): - - def create_request(self): - return ListGroups() diff --git a/tests/test_cases/test_recommend_item_segments_to_item_segment.py b/tests/test_cases/test_recommend_item_segments_to_item_segment.py index 6416e5c..4999869 100644 --- a/tests/test_cases/test_recommend_item_segments_to_item_segment.py +++ b/tests/test_cases/test_recommend_item_segments_to_item_segment.py @@ -4,10 +4,10 @@ # This file is auto-generated, do not edit # -from tests.test_cases.recommend_item_segments_to_item_segment import RecommendItemSegmentsToItemSegmentTest +from tests.test_cases.recommend_to_item_segment import RecommendToItemSegmentTest from recombee_api_client.api_requests import * -class RecommendItemSegmentsToItemSegmentTestCase(RecommendItemSegmentsToItemSegmentTest): +class RecommendItemSegmentsToItemSegmentTestCase(RecommendToItemSegmentTest): def create_request(self, context_segment_id, target_user_id, count, scenario=None, cascade_create=None, filter=None, booster=None, logic=None, expert_settings=None, return_ab_group=None): return RecommendItemSegmentsToItemSegment(context_segment_id, target_user_id, count, scenario=scenario, cascade_create=cascade_create, filter=filter, booster=booster, logic=logic, expert_settings=expert_settings, return_ab_group=return_ab_group) diff --git a/tests/test_cases/test_recommend_items_to_item_segment.py b/tests/test_cases/test_recommend_items_to_item_segment.py new file mode 100644 index 0000000..6ac4347 --- /dev/null +++ b/tests/test_cases/test_recommend_items_to_item_segment.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# This file is auto-generated, do not edit +# + +from tests.test_cases.recommend_to_item_segment import RecommendToItemSegmentTest +from recombee_api_client.api_requests import * + +class RecommendItemsToItemSegmentTestCase(RecommendToItemSegmentTest): + + def create_request(self, context_segment_id, target_user_id, count, scenario=None, cascade_create=None, return_properties=None, included_properties=None, filter=None, booster=None, logic=None, min_relevance=None, rotation_rate=None, rotation_time=None, expert_settings=None, return_ab_group=None): + return RecommendItemsToItemSegment(context_segment_id, target_user_id, count, scenario=scenario, cascade_create=cascade_create, return_properties=return_properties, included_properties=included_properties, filter=filter, booster=booster, logic=logic, min_relevance=min_relevance, rotation_rate=rotation_rate, rotation_time=rotation_time, expert_settings=expert_settings, return_ab_group=return_ab_group) diff --git a/tests/test_cases/test_remove_from_group.py b/tests/test_cases/test_remove_from_group.py deleted file mode 100644 index 3799c65..0000000 --- a/tests/test_cases/test_remove_from_group.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is auto-generated, do not edit -# - -from tests.test_cases.remove_from_group import RemoveFromGroupTest -from recombee_api_client.api_requests import * - -class RemoveFromGroupTestCase(RemoveFromGroupTest): - - def create_request(self, group_id, item_type, item_id): - return RemoveFromGroup(group_id, item_type, item_id) diff --git a/tests/test_cases/test_remove_from_series.py b/tests/test_cases/test_remove_from_series.py index 8c9ecf3..097e6f1 100644 --- a/tests/test_cases/test_remove_from_series.py +++ b/tests/test_cases/test_remove_from_series.py @@ -9,5 +9,5 @@ class RemoveFromSeriesTestCase(RemoveFromSeriesTest): - def create_request(self, series_id, item_type, item_id, time): - return RemoveFromSeries(series_id, item_type, item_id, time) + def create_request(self, series_id, item_type, item_id): + return RemoveFromSeries(series_id, item_type, item_id) diff --git a/tests/test_cases/update_auto_reql_segmentation.py b/tests/test_cases/update_auto_reql_segmentation.py index 4deb741..78f010f 100644 --- a/tests/test_cases/update_auto_reql_segmentation.py +++ b/tests/test_cases/update_auto_reql_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class UpdateAutoReqlSegmentationTest(RecombeeTest): +class UpdateAutoReqlSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,expression=None,title=None,description=None): pass diff --git a/tests/test_cases/update_manual_reql_segment.py b/tests/test_cases/update_manual_reql_segment.py index 65a16e4..dabb58f 100644 --- a/tests/test_cases/update_manual_reql_segment.py +++ b/tests/test_cases/update_manual_reql_segment.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class UpdateManualReqlSegmentTest(RecombeeTest): +class UpdateManualReqlSegmentTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,segment_id,filter,title=None): pass diff --git a/tests/test_cases/update_manual_reql_segmentation.py b/tests/test_cases/update_manual_reql_segmentation.py index 106c70f..8290ee0 100644 --- a/tests/test_cases/update_manual_reql_segmentation.py +++ b/tests/test_cases/update_manual_reql_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class UpdateManualReqlSegmentationTest(RecombeeTest): +class UpdateManualReqlSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,title=None,description=None): pass diff --git a/tests/test_cases/update_more_items.py b/tests/test_cases/update_more_items.py index 0eb4537..7bf6358 100644 --- a/tests/test_cases/update_more_items.py +++ b/tests/test_cases/update_more_items.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class UpdateMoreItemsTest(RecombeeTest): +class UpdateMoreItemsTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,filter,changes): pass diff --git a/tests/test_cases/update_property_based_segmentation.py b/tests/test_cases/update_property_based_segmentation.py index 2743419..86ecac3 100644 --- a/tests/test_cases/update_property_based_segmentation.py +++ b/tests/test_cases/update_property_based_segmentation.py @@ -4,12 +4,15 @@ # This file is auto-generated, do not edit # +import time +from abc import ABC, abstractmethod from tests.test_cases.recombee_test import RecombeeTest, InteractionsTest, RecommendationsTest from recombee_api_client.exceptions import ResponseException from recombee_api_client.api_requests import * -class UpdatePropertyBasedSegmentationTest(RecombeeTest): +class UpdatePropertyBasedSegmentationTest(RecombeeTest, ABC): + @abstractmethod def create_request(self,segmentation_id,property_name=None,title=None,description=None): pass