"""Test client for integration testing.""" from os import getenv import requests class APIClient(object): """Test API client for api integration testing.""" def __init__(self, user_id): """Create a test client of ows-timed-release.""" self.id = user_id self.base_url = getenv('TEST_BASE_URL') def get_product(self, product_id=None): """GET product live time details.""" PRODUCT = '/product/{product_id}' url = self.base_url + PRODUCT.format(product_id=product_id) response = requests.get(url) return response def post_product(self, **body): """POST product live time details.""" PRODUCT = '/product' url = self.base_url + PRODUCT response = requests.post(url, json=body) return response def put_product(self, **body): """PUT product live time details.""" product_id = body['product_id'] PRODUCT = '/product/{product_id}' url = self.base_url + PRODUCT.format(product_id=product_id) response = requests.put(url, json=body) return response def delete_product(self, product_id=None): """DELETE product live time details.""" PRODUCT = '/product/{product_id}' url = self.base_url + PRODUCT.format(product_id=product_id) response = requests.delete(url) return response