jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/394233 )

Change subject: Merge branch 'master' into deploy
......................................................................


Merge branch 'master' into deploy

d614cfd Check for duplicate subscr_cancel
584db6a Flake8 - do not use bare except
3f59aa4 Export civicrm_contact.hash to silverpop
f904c68 git.wikimedia.org -> phab
5eaa838 Prefer Civi address to contribution_tracking for country

Change-Id: I2265beffe4ea803e19b3fcf4986704cfdb1a56ec
---
D silverpop_export/tests/minimal_schema.sql
D silverpop_export/tests/test_update.py
2 files changed, 0 insertions(+), 479 deletions(-)

Approvals:
  jenkins-bot: Verified
  Ejegg: Looks good to me, approved



diff --git a/silverpop_export/tests/minimal_schema.sql 
b/silverpop_export/tests/minimal_schema.sql
deleted file mode 100644
index 4062e81..0000000
--- a/silverpop_export/tests/minimal_schema.sql
+++ /dev/null
@@ -1,134 +0,0 @@
-<<<<<<< HEAD   (6d4b6f Merge branch 'master' into deploy)
-=======
--- TODO: Do something SQLy to make *sure* we're not in a real database.
-
-drop table if exists civicrm_email;
-create table civicrm_email (
-    id int(10) unsigned auto_increment primary key,
-    contact_id int(10) unsigned,
-    email varchar(254) COLLATE utf8_unicode_ci,
-    is_primary tinyint(4) default '1',
-    on_hold tinyint(4) default '0',
-    key UI_email (email)
-);
-
-drop table if exists civicrm_contact;
-create table civicrm_contact (
-    id int(10) unsigned auto_increment primary key,
-    do_not_email tinyint(4) default '0',
-    do_not_phone tinyint(4) default '0',
-    do_not_mail tinyint(4) default '0',
-    do_not_sms tinyint(4) default '0',
-    do_not_trade tinyint(4) default '1',
-    is_opt_out tinyint(4) default '0',
-    preferred_language varchar(32) COLLATE utf8_unicode_ci,
-    hash varchar(32) COLLATE utf8_unicode_ci,
-    first_name varchar(64) COLLATE utf8_unicode_ci,
-    middle_name varchar(64) COLLATE utf8_unicode_ci,
-    last_name varchar(64) COLLATE utf8_unicode_ci,
-    is_deleted tinyint(4) default '0'
-);
-
-drop table if exists civicrm_currency;
-create table civicrm_currency (
-    id int(10) unsigned auto_increment primary key,
-    name varchar(64) COLLATE utf8_unicode_ci,
-    symbol varchar(8) COLLATE utf8_unicode_ci,
-    key UI_name (name)
-);
-insert into civicrm_currency (name, symbol)
-values
-    ('USD', '$'),
-    ('CAD', '$'),
-    ('GBP', '£'),
-    ('DZD', NULL);
-
-drop table if exists wmf_donor;
-create table wmf_donor (
-    id int(10) unsigned,
-    entity_id int(10) unsigned,
-    do_not_solicit tinyint(4),
-    is_2006_donor tinyint(4),
-    is_2007_donor tinyint(4),
-    is_2008_donor tinyint(4),
-    is_2009_donor tinyint(4),
-    is_2010_donor tinyint(4),
-    is_2011_donor tinyint(4),
-    is_2012_donor tinyint(4),
-    is_2013_donor tinyint(4),
-    is_2014_donor tinyint(4),
-    is_2015_donor tinyint(4),
-    is_2016_donor tinyint(4),
-    is_2017_donor tinyint(4),
-    is_2018_donor tinyint(4),
-    is_2019_donor tinyint(4),
-    is_2020_donor tinyint(4),
-    is_2021_donor tinyint(4),
-    is_2022_donor tinyint(4),
-    is_2023_donor tinyint(4),
-    is_2024_donor tinyint(4),
-    is_2025_donor tinyint(4),
-    last_donation_date datetime,
-    last_donation_currency varchar(255) COLLATE utf8_unicode_ci,
-    last_donation_amount decimal(20,2),
-    last_donation_usd decimal(20,2),
-    lifetime_usd_total decimal(20,2)
-);
-
-drop table if exists civicrm_contribution;
-create table civicrm_contribution (
-    id int(10) unsigned,
-    contact_id int(10) unsigned,
-    receive_date datetime,
-    total_amount decimal(20,2),
-    trxn_id varchar(255) COLLATE utf8_unicode_ci,
-    contribution_status_id int(10) unsigned
-);
-
-drop table if exists civicrm_address;
-create table civicrm_address (
-    id int(10) unsigned auto_increment primary key,
-    contact_id int(10) unsigned,
-    is_primary tinyint(4),
-    city varchar(64) COLLATE utf8_unicode_ci,
-    postal_code varchar(64) COLLATE utf8_unicode_ci,
-    country_id int(10) unsigned,
-    state_province_id int(10) unsigned,
-    timezone varchar(8) COLLATE utf8_unicode_ci
-);
-
-drop table if exists civicrm_country;
-create table civicrm_country (
-    id int(10) unsigned,
-    iso_code char(2) COLLATE utf8_unicode_ci
-);
-
-drop table if exists civicrm_state_province;
-create table civicrm_state_province (
-  id int(10) unsigned,
-  name varchar(64) COLLATE utf8_unicode_ci
-);
-
-drop table if exists wmf_contribution_extra;
-create table wmf_contribution_extra (
-    entity_id int(10) unsigned,
-    original_amount decimal(20,2),
-    original_currency varchar(255) COLLATE utf8_unicode_ci
-);
-
-drop table if exists contribution_tracking;
-create table contribution_tracking (
-    contribution_id int(10) unsigned,
-    country varchar(2)
-);
-
-drop table if exists log_civicrm_email;
-create table log_civicrm_email (
-    email varchar(254) COLLATE utf8_unicode_ci
-);
-
-drop table if exists civicrm_uf_match;
-create table civicrm_uf_match (
-    uf_name varchar(128) COLLATE utf8_unicode_ci
-);
->>>>>>> BRANCH (5eaa83 Prefer Civi address to contribution_tracking for 
country)
diff --git a/silverpop_export/tests/test_update.py 
b/silverpop_export/tests/test_update.py
deleted file mode 100644
index 41d34fb..0000000
--- a/silverpop_export/tests/test_update.py
+++ /dev/null
@@ -1,345 +0,0 @@
-<<<<<<< HEAD   (6d4b6f Merge branch 'master' into deploy)
-=======
-# -*- coding: utf-8 -*-
-import datetime
-from decimal import Decimal
-import mock
-import MySQLdb
-import os
-import warnings
-
-import database.db
-import silverpop_export.update
-
-conn = None
-db_name = None
-
-
-def setup():
-    global conn
-    global db_name
-    # FIXME: parameterize test configuration better
-    db_host = "127.0.0.1"
-    db_pass = None
-    if 'EXECUTOR_NUMBER' in os.environ:
-        # We're running under Jenkins.  Assume things.
-        db_name = "test"
-        db_user = "root"
-    else:
-        db_name = "test"
-        db_user = "test"
-
-    db_params = {"user": db_user, "host": db_host, "charset": "utf8"}
-    if db_pass:
-        db_params['passwd'] = db_pass
-
-    conn = database.db.Connection(**db_params)
-    conn.execute("set default_storage_engine=memory")
-    conn.execute("drop database if exists " + db_name)
-    conn.execute("create database " + db_name)
-    conn.db_conn.select_db(db_name)
-
-
-def test_test_setup():
-    '''
-    Set up the civcrm and export databases and run the update with no data.
-    '''
-    run_update_with_fixtures(fixture_queries=[])
-
-
-def test_duplicate():
-    '''
-    Test that we export one record for a duplicate contact.
-    '''
-
-    run_update_with_fixtures(fixture_queries=["""
-    insert into civicrm_email (contact_id, email, is_primary, on_hold) values
-        (1, 'person1@localhost', 1, 0),
-        (2, 'person1@localhost', 1, 0);
-    """, """
-    insert into civicrm_contact (id) values
-        (1),
-        (2);
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select count(*) from silverpop_export")
-    assert cursor.fetchone() == (1,)
-
-
-def test_no_donations():
-    '''
-    Test that we set the donation-related fields correctly when a contact has
-    no donations.
-    '''
-
-    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);
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select has_recurred_donation, highest_usd_amount, " +
-                   "highest_native_amount, highest_native_currency, " +
-                   "highest_donation_date, lifetime_usd_total, " +
-                   "donation_count, latest_currency, latest_native_amount, " +
-                   "latest_usd_amount, latest_donation_date from 
silverpop_export_view")
-    actual = cursor.fetchone()
-    expected = ('NO', Decimal('0.00'),
-                Decimal('0.00'), '',
-                '', Decimal('0.00'),
-                0, '', Decimal('0.00'),
-                Decimal('0.00'), '')
-    assert actual == expected
-
-
-def test_refund_history():
-    '''
-    Test that we don't include refunded donations in a donor's history
-    '''
-
-    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', 15.25, 'xyz123', 1),
-        (2, 1, '2016-05-05', 25.25, 'abc456', 9);
-    """, """
-    insert into wmf_contribution_extra (entity_id, original_amount, 
original_currency) values
-        (1, 20.15, 'CAD'),
-        (2, 35.15, 'CAD');
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select highest_usd_amount, lifetime_usd_total, 
donation_count, latest_currency, latest_native_amount, latest_usd_amount, 
latest_donation  from silverpop_export")
-    expected = (Decimal('15.25'), Decimal('15.25'), 1, 'CAD', 
Decimal('20.15'), Decimal('15.25'), datetime.datetime(2015, 1, 3))
-    assert cursor.fetchone() == expected
-
-
-def test_first_donation():
-    """
-    Test that we correctly calculate the first donation date,
-    not counting refunded donations.
-    """
-
-    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', 15.25, 'xyz123', 9),
-        (2, 1, '2016-05-05', 25.25, 'abc456', 1),
-        (3, 1, '2017-05-05', 35.35, 'def789', 1);
-    """, """
-    insert into wmf_contribution_extra (entity_id, original_amount, 
original_currency) values
-        (1, 20.15, 'CAD'),
-        (2, 35.15, 'CAD'),
-        (3, 45.25, 'CAD');
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select first_donation_date from silverpop_export")
-    expected = (datetime.datetime(2016, 5, 5),)
-    assert cursor.fetchone() == expected
-
-
-def test_timezone():
-    '''
-    Test that we export timezone records where they exist
-    '''
-
-    run_update_with_fixtures(fixture_queries=["""
-    insert into civicrm_email (contact_id, email, is_primary, on_hold) values
-        (1, 'person1@localhost', 1, 0),
-        (2, 'person1@localhost', 1, 0);
-    """, """
-    insert into civicrm_contact (id) values
-        (1),
-        (2);
-    """, """
-    insert into civicrm_country (id, iso_code) values
-        (1, 'US');
-    """, """
-    insert into civicrm_address (contact_id, is_primary, country_id, 
postal_code, timezone) values
-        (1, 1, 1, '10027', 'UTC-5');
-    """, """
-    insert into civicrm_contribution (id, contact_id, receive_date, 
total_amount, trxn_id, contribution_status_id) values
-        (1, 1, '2015-01-03', 15.25, 'xyz123', 1),
-        (2, 1, '2016-05-05', 25.25, 'abc456', 1);
-    """, """
-    insert into wmf_contribution_extra (entity_id, original_amount, 
original_currency) values
-        (1, 20.15, 'USD'),
-        (2, 35.15, 'USD');
-    """, """
-    insert into contribution_tracking (contribution_id, country) values
-        (1, 'US'),
-        (2, 'US');
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select email, country, postal_code, timezone from 
silverpop_export")
-    expected = ('person1@localhost', 'US', '10027', 'UTC-5')
-    assert cursor.fetchone() == expected
-
-
-def test_native_amount():
-    '''
-    Test that we correctly calculate the highest native amount and currency
-    '''
-
-    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),
-        (2, 1, '2016-07-07', 10.95, 'nnn777', 1),
-        (3, 1, '2016-05-05', 10.00, 'abc456', 1);
-    """, """
-    insert into wmf_contribution_extra (entity_id, original_amount, 
original_currency) values
-        (1, 1000, 'JPY'),
-        (2, 9.00, 'GBP'),
-        (3, 10.00, 'USD');
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select highest_usd_amount, highest_native_amount, 
highest_native_currency from silverpop_export")
-    expected = (Decimal('10.95'), Decimal('9'), 'GBP')
-    actual = cursor.fetchone()
-    assert actual == expected
-
-
-def test_currency_symbol():
-    '''
-    Test that we correctly pull in the currency symbol for the latest donation
-    '''
-
-    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),
-        (2, 1, '2017-07-07', 10.95, 'nnn777', 1),
-        (3, 1, '2016-05-05', 10.00, 'abc456', 1);
-    """, """
-    insert into wmf_contribution_extra (entity_id, original_amount, 
original_currency) values
-        (1, 1000, 'JPY'),
-        (2, 9.00, 'GBP'),
-        (3, 10.00, 'USD');
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select latest_currency, latest_currency_symbol from 
silverpop_export")
-    expected = ('GBP', u'£')
-    actual = cursor.fetchone()
-    assert actual == expected
-
-
-def test_export_hash():
-    '''
-    Test that we export one record for a duplicate contact.
-    '''
-
-    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, hash) values
-        (1, 'abfe829234baa87s76d');
-    """])
-
-    cursor = conn.db_conn.cursor()
-    cursor.execute("select contact_hash from silverpop_export")
-    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:
-
-        # Always return our test database connection.
-        MockConnection.return_value = conn
-
-        with mock.patch("process.globals.get_config") as MockConfig:
-            # Point all config at our test database.
-            MockConfig().civicrm_db.db = db_name
-            MockConfig().drupal_db.db = db_name
-            MockConfig().silverpop_db.db = db_name
-            MockConfig().log_civicrm_db.db = db_name
-
-            # Silence predictable warnings about "if not exists" table stuff.
-            warnings.filterwarnings('ignore', category=MySQLdb.Warning)
-
-            # Create fixtures
-            tests_dir = os.path.dirname(__file__)
-            script_path = os.path.join(tests_dir, "minimal_schema.sql")
-            database.db.run_script(script_path)
-
-            parent_dir = os.path.dirname(os.path.dirname(__file__))
-            script_path = os.path.join(parent_dir, 
"silverpop_countrylangs.sql")
-            database.db.run_script(script_path)
-
-            if fixture_path:
-                database.db.run_script(fixture_path)
-
-            if fixture_queries:
-                for statement in fixture_queries:
-                    conn.execute(statement)
-
-            # Reenable warnings
-            warnings.filterwarnings('default', category=MySQLdb.Warning)
-
-            # Run the bulk update.
-            # FIXME: Implementation should provide this as a single function.
-            update_queries = 
silverpop_export.update.load_queries('update_table.sql')
-            silverpop_export.update.run_queries(conn, update_queries)
->>>>>>> BRANCH (5eaa83 Prefer Civi address to contribution_tracking for 
country)

-- 
To view, visit https://gerrit.wikimedia.org/r/394233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2265beffe4ea803e19b3fcf4986704cfdb1a56ec
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/tools
Gerrit-Branch: deploy
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to