"""Fixtures for tests.""" import datetime import pytest import requests import application # noqa from tests import dbutils @pytest.fixture def client(): """Create instance of Flask test client.""" return application.app.test_client() @pytest.fixture def product_data(): """Sample data for product_in_store_creation.""" product_in_store_dict = { 'upc': '11111', 'orchard_product_id': 11111, 'product_id': 11111, 'store_id': 1, 'provider': 'orchard', 'itunes_vendor_id': '011111', 'delivery_date': datetime.datetime(2017, 1, 1, 12, 0, 0), 'sales_start_date': datetime.datetime(2017, 1, 1, 12, 0, 0), 'store_internal_id': 'test id', 'store_internal_status': 'test status', } return product_in_store_dict @pytest.fixture def products_data(): """Sample data with same product for different stores.""" itunes_product = { 'product_id': 1, 'orchard_product_id': 1, 'upc': '123456789012', 'itunes_vendor_id': '01', 'provider': 'orchard', 'store_id': 1, 'status': 'delivered', 'store_internal_status': 'test', 'store_internal_id': 'test', 'received_for_polling_date': '2017-01-01T19:52:22Z', 'delivery_date': '2017-01-01T19:52:22Z', 'sales_start_date': '2017-01-01T19:52:22Z', 'countries': ['USA', 'UK'], 'go_live_date': '2017-01-01T19:52:22Z' } spotify_product = itunes_product.copy() spotify_product['store_id'] = 286 return [itunes_product, spotify_product] @pytest.fixture def test_database(): """Initialize in-memory database for testing purposes.""" dbutils.db_setup_function() yield dbutils.db_teardown_function() @pytest.fixture def fake_response(): """Response object usually returned by requests module.""" response = requests.Response() response._content = b'{}' return response