def test_contacts(xero, mock_xero): contacts = xero.contacts.all() mock_contacts = mock_xero.contacts.all() assert dict_compare_keys( contacts[0], mock_contacts[0] ) == [], 'xero.contacts.all() has stuff that mock_xero doesnt' assert dict_compare_keys( mock_contacts[0], contacts[0] ) == [], 'mock_xero.contacts.all() has stuff that xero doesnt'
def test_trackingcategories(xero, mock_xero): trackingcategories = xero.trackingcategories.all() mock_trackingcategories = mock_xero.trackingcategories.all() assert dict_compare_keys( trackingcategories[0], mock_trackingcategories[0] ) == [], 'xero.trackingcategories.all() has stuff that mock_xero doesnt' assert dict_compare_keys( mock_trackingcategories[0], trackingcategories[0] ) == [], 'mock_xero.accounts.all() has stuff that xero doesnt'
def test_accounts(xero, mock_xero): accounts = xero.accounts.all() mock_accounts = mock_xero.accounts.all() assert dict_compare_keys( accounts[0], mock_accounts[0] ) == [], 'xero.accounts.all() has stuff that mock_xero doesnt' assert dict_compare_keys( mock_accounts[0], accounts[0] ) == [], 'mock_xero.accounts.all() has stuff that xero doesnt'
def test_dict_compare(): d1 = { 'k1' : 'xxx', 'k2' : 2, 'k3' : [1, 2], 'k4' : { 'k41' : [2], 'k42' : { 'k421' : 20}} } d2 = { 'k1' : 'xyx', 'k3' : [1, 2], 'k4' : { 'k42' : { 'k421' : 20}} } d3 = { 'k1' : 'xyz', 'k3' : [3, 2], 'k4' : { 'k42' : { 'k421' : 40}} } assert dict_compare_keys(d1, d2) == ['->k2', '->k4->k41'], 'not identifying diff properly' assert dict_compare_keys(d2, d3) == [], 'should return no diff'
def test_invoices_all(xero, mock_xero): invoices = xero.invoices.all() mock_invoices = mock_xero.invoices.all() assert dict_compare_keys( invoices[0], mock_invoices[0] ) == [], 'xero.invoices.all() has stuff that mock_xero doesnt' # Temporarily commenting this out because sometimes xero invoices have currency rate but sometimes they dont # assert dict_compare_keys(mock_invoices[0], invoices[0]) == [], 'mock_xero.accounts.all() has stuff that xero doesnt' invoices = xero.invoices.get(invoices[0]['InvoiceID']) mock_invoices = mock_xero.invoices.get('foo') assert dict_compare_keys( invoices[0], mock_invoices[0] ) == [], 'xero.invoices.get() has stuff that mock_xero doesnt'
def test_invoices(xec): dbconn = xec._XeroExtractConnector__dbconn xero = xec._XeroExtractConnector__xero ids = xec.extract_invoices() xero_data = xero.invoices.all()[0] db_data = dbconn_table_row_dict(dbconn, 'xero_extract_invoices') assert dict_compare_keys(db_data, xero_data) == [], 'db table has some columns that xero doesnt' assert ids == ['9f5bca33-8590-4b6f-acfb-e85712b10217'], 'return value messed up'
def test_trackingoptions(xec): dbconn = xec._XeroExtractConnector__dbconn xero = xec._XeroExtractConnector__xero ids = xec.extract_trackingcategories() xero_data = xero.trackingcategories.all()[0]['Options'][0] db_data = dbconn_table_row_dict(dbconn, 'xero_extract_trackingoptions') assert dict_compare_keys(db_data, xero_data) == ['->TrackingCategoryID'], 'db table has some columns that xero doesnt' assert dbconn_table_num_rows(dbconn, 'xero_extract_trackingoptions') == len(xero.trackingcategories.all()[0]['Options']), 'row count mismatch'
def test_contacts(xec): dbconn = xec._XeroExtractConnector__dbconn xero = xec._XeroExtractConnector__xero ids = xec.extract_contacts() xero_data = xero.contacts.all()[0] db_data = dbconn_table_row_dict(dbconn, 'xero_extract_contacts') assert dict_compare_keys(db_data, xero_data) == [], 'db table has some columns that xero doesnt' assert dbconn_table_num_rows(dbconn, 'xero_extract_contacts') == len(xero.contacts.all()), 'row count mismatch' assert len(ids) == 44, 'return value messed up'
def test_trackingcategories(xec): dbconn = xec._XeroExtractConnector__dbconn xero = xec._XeroExtractConnector__xero ids = xec.extract_trackingcategories() xero_data = xero.trackingcategories.all()[0] db_data = dbconn_table_row_dict(dbconn, 'xero_extract_trackingcategories') assert dict_compare_keys(db_data, xero_data) == [], 'db table has some columns that xero doesnt' assert dbconn_table_num_rows(dbconn, 'xero_extract_trackingcategories') == len(xero.trackingcategories.all()), 'row count mismatch' assert ids == ['fa437cfd-f005-4538-ae84-943857da5c8c'], 'return value messed up'
def test_extract_by_type_name(nsec, type_name): dbconn = nsec._NetSuiteExtractConnector__dbconn ns = nsec._NetSuiteExtractConnector__ns nsec_extract_fn = getattr(nsec, f'extract_{type_name}') ids = nsec_extract_fn() ns_get_all_fn = getattr(getattr(ns, f'{type_name}'), 'get_all') ns_data = ns_get_all_fn() db_data = dbconn_table_row_dict(dbconn, f'ns_extract_{type_name}') assert dict_compare_keys( db_data, ns_data[0]) == [], 'db table has some columns that ns doesnt' assert dbconn_table_num_rows( dbconn, f'ns_extract_{type_name}') == len(ns_data), 'row count mismatch'