"""Do required things with db prior to the tests.""" import mysql.connector cnx = mysql.connector.connect( host='reserves-take-mysql', port='3306', database='royalty_accounting', user='db_user', password='db_pass' ) cursor = cnx.cursor() query = """ INSERT INTO account ( account_id, account_name, created_by, created_at, last_modified_by, last_modified ) VALUES ( 35968, 'integration tests', 1, '2021-01-01 00:00:00', 1, '2021-01-01 00:00:00' ); """ cursor.execute(query) cnx.commit() query = """ INSERT 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 ( 500005, 1, 1, 'test', '2021-05-06', '2021-05-27', 'vz', NOW(), 'vz', NOW() ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO accounting_period ( accounting_period_id, accounting_period_name, accounting_period_status, contract_type, closed_date, statement_period_id, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 'period', 'locked', 'distribution', null, 282, 'vz', '2021-05-05 09:39:01', 'vz', '2021-05-05 09:39:04' ); """ cursor.execute(query) cnx.commit() query = """ UPDATE run_controller t SET t.run_controller_name = 'run-thru' WHERE t.run_controller_id = 2686 """ cursor.execute(query) cnx.commit() query = """ INSERT INTO run_controller_contract ( run_controller_contract_id, run_controller_id, contract_id ) VALUES ( 1, 2686, 500005 ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO accounting_run ( accounting_run_id, accounting_period_id, run_controller_id, run_status, start_date, summary_export_url, created_by, created_at, last_modified_by, last_modified ) VALUES ( 2, 1, 2686, 'Committed', '2021-05-06 04:17:37', null, 'vz', '2021-05-05 09:45:47', 'vz', '2021-05-05 09:45:53' ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO abacus_event ( abacus_event_id, statement_period_id, event_name, target_type, target_id, event_date, previous_abacus_event_id, rolled_back_at ) VALUES ( 1, 282, 'take_reserves', 'accounting_run', 2, '2021-03-09 08:10:20.000000', null, null ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO contract_reserve( contract_reserve_id, contract_id, reserve_rate, reserve_release_offset_in_months, installments_in_months, release_schedule, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 500005, 1.90, 1, 2, '["0.50", "0.50"]', 'Test', NOW(), 'Test', NOW() ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO account_contract( account_contract_id, account_id, contract_id ) VALUES ( 1, 35968, 500005 ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO account_payment_term ( account_payment_term_id, account_id, currency_code, payment_minimum, payment_entity_id, payment_schedule, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 35968, 'GBP', 42.00, 1, null, 'Test', NOW(), 'Test', NOW() ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO account_tax_info( account_tax_info_id, account_id, country_of_tax_residence, is_sba_signed, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 35968, 'USA', 0, 'test', '2021-10-29 13:22:52', 'test', '2021-10-29 13:22:58' ); """ cursor.execute(query) cnx.commit() query = """ INSERT INTO ledger_deposit ( ledger_deposit_id, account_id, contract_id, abacus_event_id, currency_code, rounded_amount, remaining_amount, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 35968, 500005, 1, 'GBP', 5.00, 10.000000000000000000, 'vz', '2022-07-27 05:48:08', 'vz', '2022-07-27 05:48:11' ); """ cursor.execute(query) cnx.commit() cnx.close() print('DB fixtures created.')