"""Create database fixtures for tests.""" import mysql.connector cnx = mysql.connector.connect( host='adjustment-file-import-mysql', port='3306', database='royalty_accounting', user='db_user', password='db_pass' ) cursor = cnx.cursor() insert_accounts = """ INSERT IGNORE INTO account ( account_id, account_name, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 'Test Account 1', 'test', NOW(), 'test', NOW() ), ( 2, 'Test Account 2', 'test', NOW(), 'test', NOW() ), ( 3, 'Test Account 3', 'test', NOW(), 'test', NOW() ), ( 4, 'Test Account 4', 'test', NOW(), 'test', NOW() ), ( 5, 'Test Account 5', 'test', NOW(), 'test', NOW() ), ( 6, 'Test Account 6', 'test', NOW(), 'test', NOW() ), ( 7, 'Test Account 7', 'test', NOW(), 'test', NOW() ), ( 8, 'Test Account 8', 'test', NOW(), 'test', NOW() ), ( 9, 'Test Account 9', 'test', NOW(), 'test', NOW() ); """ cursor.execute(insert_accounts) cnx.commit() insert_contracts = """ INSERT IGNORE INTO contract ( contract_id, reference_signing_entity_id, reference_sap_profit_center_id, contract_name, term_start, term_end, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 1, 1, 'Test Contract 1', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 2, 1, 1, 'Test Contract 2', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 3, 1, 1, 'Test Contract 3', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 4, 1, 1, 'Test Contract 4', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 5, 1, 1, 'Test Contract 5', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 6, 1, 1, 'Test Contract 6', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 7, 1, 1, 'Test Contract 7', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 8, 1, 1, 'Test Contract 8', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ), ( 9, 1, 1, 'Test Contract 9', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ); """ cursor.execute(insert_contracts) cnx.commit() insert_account_contracts = """ INSERT IGNORE INTO account_contract( account_contract_id, account_id, contract_id ) VALUES ( 1, 1, 1 ), ( 2, 2, 2 ), ( 3, 3, 3 ), ( 4, 4, 4 ), ( 5, 5, 5 ), ( 6, 6, 6 ), ( 7, 7, 7 ), ( 8, 8, 8 ), ( 9, 9, 9 ); """ cursor.execute(insert_account_contracts) cnx.commit() insert_adjustment_files = """ INSERT IGNORE INTO statement_period_adjustment_file ( statement_period_adjustment_file_id, statement_period_id, file_name, valid_file_location, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 282, 'adjustment_file_import_lambda_fixture.xlsx', 's3://qa-abacus-adjustments/test_fixtures/adjustment_file_import_lambda_fixture.xlsx', 'test', NOW(), 'test', NOW() ); """ cursor.execute(insert_adjustment_files) cnx.commit() insert_abacus_events = """ INSERT IGNORE INTO abacus_event ( abacus_event_id, statement_period_id, event_name, target_type, target_id, event_date ) VALUES ( 1, 282, 'adjustment_file_worksheet_import', 'statement_period_adjustment_file', 1, NOW() ); """ cursor.execute(insert_abacus_events) cnx.commit() cnx.close() print('DB fixtures created.')