from assertpy import assert_that import os from testhelpers.integ import ( absolute_file_path, get_request_assert ) cwd = os.path.dirname(os.path.abspath(__file__)) request_bodies_path = absolute_file_path(cwd, "json_request_bodies.json") schemas_path = absolute_file_path(cwd, "json_schemas.json") recommendation_api_url = os.getenv("RECOMMENDATIONS_API_URL") or sys.exit( "Please provide an environment variable RECOMMENDATIONS_API_URL" ) DEFAULT_PARAMS = {":userID": 5097, ":feature": "product_detail_related"} def test_get_recommendations_should_return_products_with_correct_schema(): endpoint = "/recommendations?userID=:userID&feature=:feature" params = DEFAULT_PARAMS get_request_assert(recommendation_api_url, endpoint, schemas_path, params) def test_get_recommendations_with_numResults_should_return_exact_number_of_result(): num_results = 3 endpoint = "/recommendations?userID=:userID&feature=:feature&numResults=:numResults" params = { **DEFAULT_PARAMS, ":numResults": num_results,
import testhelpers.integ as integhelpers import os from dotenv import load_dotenv load_dotenv() cwd = os.path.dirname(os.path.abspath(__file__)) request_bodies_path = integhelpers.absolute_file_path(cwd, "json_request_bodies.json") schemas_path = integhelpers.absolute_file_path(cwd, "json_schemas.json") orders_api_url = os.getenv('ORDERS_API_URL') def test_get_orders_all(): endpoint = "/orders/all" integhelpers.get_request_assert(orders_api_url, endpoint, schemas_path) def test_get_orders_id(): endpoint = "/orders/id/:order_id" params = {":order_id": os.getenv('TEST_ORDER_ID')} integhelpers.get_request_assert(orders_api_url, endpoint, schemas_path, params) def test_put_orders_id(): endpoint = "/orders/id/:order_id" params = {":order_id": os.getenv('TEST_ORDER_ID')} integhelpers.put_request_assert(orders_api_url, endpoint, request_bodies_path, schemas_path, params)