Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/393816 )
Change subject: Don't use 'XX' country from contribution_tracking ...................................................................... Don't use 'XX' country from contribution_tracking Bug: T181424 Change-Id: Iec7d2d4f9cf575c379c952a3c10ebac4c5f8c2a3 --- M silverpop_export/tests/test_update.py M silverpop_export/update_table.sql 2 files changed, 36 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/tools refs/changes/16/393816/1 diff --git a/silverpop_export/tests/test_update.py b/silverpop_export/tests/test_update.py index 8db6bca..7e3fa72 100644 --- a/silverpop_export/tests/test_update.py +++ b/silverpop_export/tests/test_update.py @@ -18,7 +18,7 @@ global db_name # FIXME: parameterize test configuration better db_host = "127.0.0.1" - db_pass = None + db_pass = "test" if 'EXECUTOR_NUMBER' in os.environ: # We're running under Jenkins. Assume things. db_name = "test" @@ -268,6 +268,39 @@ assert cursor.fetchone() == ('abfe829234baa87s76d',) +def test_bad_ct_country(): + ''' + Test that we use the Civi address in place of XX contribution_tracking + ''' + + run_update_with_fixtures(fixture_queries=[""" + insert into civicrm_email (contact_id, email, is_primary, on_hold) values + (1, 'person1@localhost', 1, 0); + """, """ + insert into civicrm_contact (id) values + (1); + """, """ + insert into civicrm_contribution (id, contact_id, receive_date, total_amount, trxn_id, contribution_status_id) values + (1, 1, '2015-01-03', 9.50, 'xyz123', 1); + """, """ + insert into wmf_contribution_extra (entity_id, original_amount, original_currency) values + (1, 1000, 'JPY'); + """, """ + insert into contribution_tracking (contribution_id, country) values + (1, 'XX'); + """, """ + insert into civicrm_country (id, iso_code) values + (1, 'PE'); + """, """ + insert into civicrm_address (contact_id, is_primary, country_id) values + (1, 1, 1); + """]) + + cursor = conn.db_conn.cursor() + cursor.execute("select country from silverpop_export") + assert cursor.fetchone() == ('PE',) + + def run_update_with_fixtures(fixture_path=None, fixture_queries=None): with mock.patch("database.db.Connection") as MockConnection: diff --git a/silverpop_export/update_table.sql b/silverpop_export/update_table.sql index 4ca34ae..daaca4b 100755 --- a/silverpop_export/update_table.sql +++ b/silverpop_export/update_table.sql @@ -125,7 +125,8 @@ WHERE ex.contact_id = ct.contact_id AND dct.contribution_id = ct.id AND - dct.country IS NOT NULL; + dct.country IS NOT NULL AND + dct.country <> 'XX'; CREATE TABLE silverpop_export_highest( email varchar(255) PRIMARY KEY, -- To view, visit https://gerrit.wikimedia.org/r/393816 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iec7d2d4f9cf575c379c952a3c10ebac4c5f8c2a3 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/tools Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits