"""Fixtures for the test cases.""" from datetime import datetime import pytest from prs.constants import tools_message @pytest.fixture def update_tool_log_response_success(): """Return a tool_log entry for testing success response.""" return { 'tool_log_id': 1, 'tool_name': 'Label Details', 'society_id': 41, 'time_start': datetime(2017, 7, 25, 14, 8, 17), 'tool_switches': '[]', 'input_text': '7689', 'status': -1, 'comment': '12345', 'mysql_proc_id': 200, 'progress': 'Fetching eligible labels', 'file_code': 'B7A81', 'user_ip': '::1' } @pytest.fixture def update_tool_log_response_failure(): """Return a tool_log entry for testing failure response.""" return { 'tool_log_id': 5, 'tool_name': 'Label Details', 'society_id': 41, 'time_start': datetime(2017, 7, 25, 14, 8, 17), 'tool_switches': '[]', 'input_text': '7689', 'status': -1, 'comment': '12345', 'mysql_proc_id': 200, 'progress': 'Fetching eligible labels', 'file_code': 'B7A81', 'user_ip': '::1' } @pytest.fixture def label_data_response(): """Return label_data_response for testing success response.""" return [{'columns': column_labels_success(), 'rows': label_data_success()}] @pytest.fixture def label_query_response(): """Return label_data as a dict for testing success response.""" return [{'assigned_to': '', 'collection_split': '', 'collection_territory': '', 'cont_end': '9999-12-31', 'cont_start': '2004-04-27', 'contact_email': '', 'currency_code': 'USD', 'currency_id': 1, 'digital_split': 0.5, 'email': 'email1@theorchard.com', 'is_contract_active': 'Y', 'is_distributor': 'Y', 'is_owned_and_operated': 'N', 'is_signed': 'Y', 'label_country': 'Argentina', 'label_country_id': 1, 'last_delivery_date': 'NONE', 'owner': 'DMGI', 'split_id': 4999, 'split_vendor_id': 547, 'sx_split': 0.0, 'territory_carve_out': '', 'vendor_id': 547, 'vendor_name': 'RIQUELME'}, {'assigned_to': '', 'collection_split': '', 'collection_territory': '', 'cont_end': '9999-12-31', 'cont_start': '2004-04-27', 'contact_email': '', 'currency_code': 'USD', 'currency_id': 1, 'digital_split': 0.5, 'email': 'email1@theorchard.com', 'is_contract_active': 'Y', 'is_distributor': 'Y', 'is_owned_and_operated': 'N', 'is_signed': 'Y', 'label_country': 'Netherlands', 'label_country_id': 23, 'last_delivery_date': 'NONE', 'owner': 'DMGI', 'split_id': 5000, 'split_vendor_id': 548, 'sx_split': 0.0, 'territory_carve_out': '', 'vendor_id': 548, 'vendor_name': 'MICHAEL GEORGE'}, {'assigned_to': '', 'collection_split': '', 'collection_territory': '', 'cont_end': '9999-12-31', 'cont_start': '2004-04-27', 'contact_email': '', 'currency_code': 'USD', 'currency_id': 1, 'digital_split': 0.5, 'email': 'email1@theorchard.com', 'is_contract_active': 'Y', 'is_distributor': 'Y', 'is_owned_and_operated': 'N', 'is_signed': 'Y', 'label_country': 'USA', 'label_country_id': 1, 'last_delivery_date': 'NONE', 'owner': 'DMGI', 'split_id': 5001, 'split_vendor_id': 549, 'sx_split': 0.0, 'territory_carve_out': '', 'vendor_id': 549, 'vendor_name': 'PETE GEORGE'}] @pytest.fixture def label_data_success(): """Return label detail entries for testing success response.""" return [(547, 'RIQUELME', 'DMGI', 'Argentina', 4999, 547, '2004-04-27', '9999-12-31', 0.5, 1, 'USD', '', '', '', 0.0, 'Y', 'Y', 'N', '', 'email1@theorchard.com', 'NONE', '', 'Y', 1), (548, 'MICHAEL GEORGE', 'DMGI', 'Netherlands', 5000, 548, '2004-08-10', '9999-12-31', 0.5, 1, 'USD', '', '', '', 0.0, 'Y', 'Y', 'N', 'Artist/Label Relations', 'email2@theorchard.com', 'NONE', '', 'Y', 1), (549, 'PETE GEORGE', 'DMGI', 'USA', 5001, 549, '2004-08-31', '9999-12-31', 0.5, 1, 'USD', '', '', '', 0.0, 'Y', 'Y', 'N', 'Artist/Label Relations', 'email1@theorchard.com', 'NONE', '', 'Y', 1)] @pytest.fixture def column_labels_success(): """Return column label entries for testing success response.""" return ['vendor_id', 'vendor_name', 'owner', 'label_country', 'split_id', 'split_vendor_id', 'cont_start', 'cont_end', 'digital_split', 'currency_id', 'currency_code', 'collection_territory', 'territory_carve_out', 'collection_split', 'sx_split', 'is_signed', 'is_contract_active', 'is_owned_and_operated', 'assigned_to', 'email', 'last_delivery_date', 'contact_email', 'is_distributor', 'label_country_id'] @pytest.fixture def label_details_response(): """Return label_details_response for testing success response.""" return { 's3_url': 'https://bucket-name.s3.amazonaws.com/' 'tool/filename.csv?AWSAccessKeyId=RANDOMKEY&' 'Signature=RANDOMSIGN&Expires=1502967998', 'message': tools_message.CSV_GENERATION_SUCCESS_MESSAGE } @pytest.fixture def label_delivery_history_response(): """Return label_delivery_history success response.""" return [[101, '2017-09-05'], [102, '2017-09-09'], [102, '2017-09-05'], [110, '2017-09-10']] @pytest.fixture def tool_param_data(): """Return tool_param_data for testing.""" return { 'country_id': 0, 'ignore_rome': 0, 'include_local_labels': 0, 'check_blacklist': 1, 'manual_label': 'report for xyz', 'eligible_vendor_list': '547,548' } @pytest.fixture def tool_param_data_initialize_tool(): """Return tool_param_data_initialize_tool for testing.""" return { 'country_id': 0, 'ignore_rome': 0, 'include_local_labels': 0, 'check_blacklist': 1, 'manual_label': 'report for xyz', 'eligible_vendor_list': {547, 548} } @pytest.fixture def tool_param_data_vendor_list_error(): """Return tool_param_data_vendor_list_error for testing.""" return { 'country_id': 0, 'ignore_rome': 0, 'include_local_labels': 0, 'check_blacklist': 1, 'manual_label': 'report for xyz', 'eligible_vendor_list': '547,548,abcd' } @pytest.fixture def tool_param_data_country_id_not_zero(): """Return tool_param_data for testing.""" return { 'country_id': 1, 'ignore_rome': 0, 'include_local_labels': 0, 'check_blacklist': 1, 'manual_label': 'report for xyz', 'eligible_vendor_list': '547,548' }