From cf0a30433cdae6f91c5b5994b579ba427f84ac68 Mon Sep 17 00:00:00 2001 From: Wil Thieme Date: Sat, 7 Sep 2024 10:51:48 -0400 Subject: [PATCH] sort imports --- parsons/actblue/actblue.py | 5 ++-- parsons/action_builder/action_builder.py | 3 +- parsons/action_kit/action_kit.py | 5 ++-- parsons/action_network/action_network.py | 1 + parsons/airtable/airtable.py | 5 ++-- parsons/alchemer/alchemer.py | 2 ++ parsons/auth0/auth0.py | 1 + parsons/aws/__init__.py | 4 +-- parsons/aws/aws_async.py | 1 - parsons/aws/lambda_distribute.py | 11 +++---- parsons/aws/s3.py | 5 ++-- parsons/azure/azure_blob_storage.py | 1 - parsons/bill_com/bill_com.py | 4 ++- parsons/bloomerang/bloomerang.py | 5 ++-- parsons/box/box.py | 3 +- parsons/braintree/braintree.py | 1 - parsons/capitol_canary/capitol_canary.py | 4 ++- parsons/catalist/catalist.py | 2 +- parsons/census/census.py | 5 ++-- parsons/community/community.py | 5 ++-- parsons/copper/copper.py | 8 +++-- parsons/crowdtangle/crowdtangle.py | 6 ++-- parsons/databases/alchemy.py | 3 +- parsons/databases/database/database.py | 3 +- parsons/databases/database_connector.py | 1 + parsons/databases/discover_database.py | 4 +-- parsons/databases/mysql/create_table.py | 7 +++-- parsons/databases/mysql/mysql.py | 19 ++++++------ parsons/databases/postgres/postgres.py | 10 +++---- parsons/databases/postgres/postgres_core.py | 10 ++++--- .../postgres/postgres_create_statement.py | 7 +++-- parsons/databases/redshift/redshift.py | 30 ++++++++++--------- parsons/databases/redshift/rs_copy_table.py | 5 ++-- parsons/databases/redshift/rs_create_table.py | 7 +++-- parsons/donorbox/donorbox.py | 10 +++---- parsons/etl/__init__.py | 2 +- parsons/etl/tofrom.py | 8 +++-- parsons/facebook_ads/facebook_ads.py | 8 +++-- parsons/freshdesk/freshdesk.py | 7 +++-- parsons/geocode/census_geocoder.py | 8 +++-- parsons/github/github.py | 2 +- parsons/google/google_admin.py | 1 - parsons/google/google_bigquery.py | 4 +-- parsons/google/google_civic.py | 3 +- parsons/google/google_cloud_storage.py | 4 +-- parsons/google/google_sheets.py | 2 +- parsons/google/utilities.py | 1 - parsons/hustle/hustle.py | 10 ++++--- parsons/mailchimp/mailchimp.py | 1 + parsons/mobilecommons/mobilecommons.py | 12 ++++---- parsons/mobilize_america/ma.py | 12 ++++---- parsons/newmode/newmode.py | 6 ++-- parsons/ngpvan/activist_codes.py | 3 +- parsons/ngpvan/bulk_import.py | 8 ++--- parsons/ngpvan/canvass_responses.py | 3 +- parsons/ngpvan/changed_entities.py | 3 +- parsons/ngpvan/codes.py | 3 +- parsons/ngpvan/contact_notes.py | 3 +- parsons/ngpvan/custom_fields.py | 3 +- parsons/ngpvan/email.py | 3 +- parsons/ngpvan/locations.py | 3 +- parsons/ngpvan/people.py | 5 ++-- parsons/ngpvan/printed_lists.py | 3 +- parsons/ngpvan/saved_lists.py | 6 ++-- parsons/ngpvan/scores.py | 8 +++-- parsons/ngpvan/signups.py | 3 +- parsons/ngpvan/supporter_groups.py | 3 +- parsons/ngpvan/survey_questions.py | 3 +- parsons/ngpvan/targets.py | 4 ++- parsons/ngpvan/van.py | 27 +++++++++-------- parsons/ngpvan/van_connector.py | 4 ++- parsons/notifications/gmail.py | 6 ++-- parsons/notifications/sendmail.py | 19 ++++++------ parsons/notifications/slack.py | 7 ++--- parsons/pdi/flags.py | 3 +- parsons/pdi/pdi.py | 29 +++++++++--------- parsons/phone2action/p2a.py | 3 +- parsons/quickbase/quickbase.py | 2 +- parsons/redash/redash.py | 3 +- parsons/rockthevote/rtv.py | 4 +-- parsons/salesforce/salesforce.py | 6 ++-- parsons/scytl/scytl.py | 11 +++---- parsons/sftp/utilities.py | 1 + parsons/shopify/shopify.py | 2 +- parsons/targetsmart/targetsmart_api.py | 1 + parsons/targetsmart/targetsmart_automation.py | 15 +++++----- parsons/tools/credential_tools.py | 5 ++-- parsons/turbovote/turbovote.py | 6 ++-- parsons/twilio/twilio.py | 6 ++-- parsons/utilities/api_connector.py | 5 ++-- parsons/utilities/datetime.py | 3 +- parsons/utilities/oauth_api_connector.py | 3 +- parsons/utilities/ssh_utilities.py | 3 +- parsons/utilities/zip_archive.py | 1 + parsons/zoom/zoom.py | 7 +++-- setup.py | 1 + test/fixtures.py | 2 +- test/test_actblue/test_actblue.py | 5 ++-- .../test_action_builder.py | 8 +++-- test/test_action_kit.py | 4 +-- .../test_action_network.py | 6 ++-- test/test_airtable/test_airtable.py | 9 +++--- test/test_alchemer/test_getresponses.py | 3 +- test/test_alchemer/test_getsurveys.py | 3 +- test/test_auth0.py | 1 + test/test_aws_async.py | 2 +- test/test_azure/test_azure_blob_storage.py | 2 -- test/test_bill_com/test_bill_com.py | 8 +++-- test/test_bloomerang/test_bloomerang.py | 21 ++++++------- test/test_braintree/test_braintree.py | 5 ++-- test/test_capitol_canary.py | 9 +++--- test/test_catalist/conftest.py | 5 ++-- test/test_catalist/test_catalist.py | 6 ++-- test/test_census/test_census.py | 6 ++-- test/test_civis.py | 3 +- test/test_community/test_community.py | 3 +- test/test_controlshift/test_controlshift.py | 8 +++-- test/test_copper/test_copper.py | 12 ++++---- test/test_credential_tools.py | 3 +- test/test_crowdtangle/test_crowdtangle.py | 8 +++-- test/test_databases/fakes.py | 3 +- test/test_databases/test_bigquery.py | 4 +-- test/test_databases/test_database.py | 12 ++------ test/test_databases/test_dbsync.py | 7 +++-- test/test_databases/test_discover_database.py | 7 +++-- test/test_databases/test_mysql.py | 7 +++-- test/test_databases/test_postgres.py | 7 +++-- test/test_databases/test_redshift.py | 9 +++--- test/test_donorbox/test_donorbox.py | 8 ++--- test/test_facebook_ads.py | 3 +- test/test_formstack/test_formstack.py | 13 ++++---- test/test_freshdesk/test_freshdesk.py | 6 ++-- test/test_geocoder/test_census_geocoder.py | 10 ++++--- test/test_github/test_github.py | 4 +-- test/test_gmail/test_gmail.py | 11 +++---- test/test_google/test_google_admin.py | 7 +++-- test/test_google/test_google_cloud_storage.py | 8 ++--- test/test_google/test_google_sheets.py | 7 +++-- test/test_google/test_googlecivic.py | 13 ++++---- test/test_hustle/test_hustle.py | 8 +++-- test/test_mailchimp/test_mailchimp.py | 6 ++-- test/test_mobilecommons/test_mobilecommons.py | 7 +++-- test/test_mobilize/test_mobilize_america.py | 6 ++-- test/test_newmode/test_newmode.py | 1 + test/test_p2a.py | 9 +++--- test/test_pdi/conftest.py | 5 ++-- test/test_pdi/test_events.py | 1 + test/test_pdi/test_flag_ids.py | 9 +++--- test/test_pdi/test_pdi.py | 5 ++-- test/test_quickbase/test_quickbase.py | 4 ++- test/test_redash.py | 7 +++-- test/test_rockthevote/test_rtv.py | 2 +- test/test_s3.py | 10 ++++--- test/test_salesforce/test_salesforce.py | 1 + test/test_scytl/test_scytl.py | 6 ++-- test/test_sendmail.py | 11 +++---- test/test_sftp.py | 18 +++++------ test/test_sftp_ssh.py | 15 ++++------ test/test_shopify.py | 6 ++-- test/test_sisense/test_sisense.py | 13 ++++---- test/test_slack/test_slack.py | 11 ++++--- test/test_smtp.py | 3 +- test/test_targetsmart/test_targetsmart_api.py | 14 +++++---- .../test_targetsmart_automation.py | 5 ++-- .../test_targetsmart_smartmatch.py | 2 +- test/test_turbovote/test_turbovote.py | 6 ++-- test/test_twilio/test_twilio.py | 1 + test/test_utilities.py | 15 +++++----- .../test_format_phone_number.py | 1 + test/test_utilities/test_ssh_utilities.py | 3 +- test/test_van/test_activist_codes.py | 6 ++-- test/test_van/test_bulkimport.py | 8 +++-- test/test_van/test_changed_entities.py | 8 +++-- test/test_van/test_codes.py | 8 +++-- test/test_van/test_contact_notes.py | 8 +++-- test/test_van/test_custom_fields.py | 7 +++-- test/test_van/test_email.py | 6 ++-- test/test_van/test_events.py | 7 +++-- test/test_van/test_locations.py | 7 +++-- test/test_van/test_ngpvan.py | 6 ++-- test/test_van/test_people.py | 12 ++++---- test/test_van/test_printed_lists.py | 6 ++-- test/test_van/test_saved_lists.py | 8 +++-- test/test_van/test_scores.py | 9 +++--- test/test_van/test_signups.py | 6 ++-- test/test_van/test_targets.py | 8 +++-- test/test_zoom.py | 1 + test/utils.py | 4 ++- .../sample_code/apply_activist_code.py | 5 ++-- .../civis_job_status_slack_alert.py | 3 +- .../sample_code/mysql_to_googlesheets.py | 4 ++- .../sample_code/ngpvan_sample_list.py | 1 + .../sample_code/ngpvan_sample_printed_list.py | 4 +-- .../sample_code/opt_outs_everyaction.py | 9 +++--- .../sample_code/s3_to_redshift.py | 3 +- useful_resources/sample_code/s3_to_s3.py | 3 +- .../sample_code/update_user_in_actionkit.py | 5 ++-- useful_resources/sample_code/zoom_to_van.py | 1 + 198 files changed, 690 insertions(+), 516 deletions(-) diff --git a/parsons/actblue/actblue.py b/parsons/actblue/actblue.py index b5981319db..2ccab9ccda 100644 --- a/parsons/actblue/actblue.py +++ b/parsons/actblue/actblue.py @@ -1,8 +1,9 @@ import logging import time -from parsons.utilities.api_connector import APIConnector -from parsons.utilities import check_env + from parsons.etl import Table +from parsons.utilities import check_env +from parsons.utilities.api_connector import APIConnector logger = logging.getLogger(__name__) diff --git a/parsons/action_builder/action_builder.py b/parsons/action_builder/action_builder.py index 5249213a7b..66717cbe18 100644 --- a/parsons/action_builder/action_builder.py +++ b/parsons/action_builder/action_builder.py @@ -1,8 +1,9 @@ import json +import logging + from parsons import Table from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector -import logging logger = logging.getLogger(__name__) diff --git a/parsons/action_kit/action_kit.py b/parsons/action_kit/action_kit.py index 99be390e16..2b8fbfb816 100644 --- a/parsons/action_kit/action_kit.py +++ b/parsons/action_kit/action_kit.py @@ -1,8 +1,9 @@ import json import logging -import requests -import time import math +import time + +import requests from parsons.etl.table import Table from parsons.utilities import check_env diff --git a/parsons/action_network/action_network.py b/parsons/action_network/action_network.py index 4145a611f3..cdd68cc708 100644 --- a/parsons/action_network/action_network.py +++ b/parsons/action_network/action_network.py @@ -3,6 +3,7 @@ import re import warnings from typing import Dict, List, Union + from parsons import Table from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector diff --git a/parsons/airtable/airtable.py b/parsons/airtable/airtable.py index 0a29f6460b..6a98e93c07 100644 --- a/parsons/airtable/airtable.py +++ b/parsons/airtable/airtable.py @@ -1,8 +1,9 @@ +import logging + from pyairtable import Api as client + from parsons.etl import Table from parsons.utilities import check_env -import logging - logger = logging.getLogger(__name__) diff --git a/parsons/alchemer/alchemer.py b/parsons/alchemer/alchemer.py index a5950fe9ff..8b6b6e9356 100644 --- a/parsons/alchemer/alchemer.py +++ b/parsons/alchemer/alchemer.py @@ -1,5 +1,7 @@ import logging + import surveygizmo + from parsons.etl import Table from parsons.utilities import check_env diff --git a/parsons/auth0/auth0.py b/parsons/auth0/auth0.py index adb07f368c..29049053e5 100644 --- a/parsons/auth0/auth0.py +++ b/parsons/auth0/auth0.py @@ -4,6 +4,7 @@ import time import requests + from parsons.etl.table import Table from parsons.utilities import check_env diff --git a/parsons/aws/__init__.py b/parsons/aws/__init__.py index b0db4e9b5b..e92bfd6f6f 100644 --- a/parsons/aws/__init__.py +++ b/parsons/aws/__init__.py @@ -1,5 +1,5 @@ -from parsons.aws.s3 import S3 -from parsons.aws.lambda_distribute import distribute_task from parsons.aws.aws_async import event_command +from parsons.aws.lambda_distribute import distribute_task +from parsons.aws.s3 import S3 __all__ = ["S3", "distribute_task", "event_command"] diff --git a/parsons/aws/aws_async.py b/parsons/aws/aws_async.py index 68f1419420..cec5c9fc81 100644 --- a/parsons/aws/aws_async.py +++ b/parsons/aws/aws_async.py @@ -5,7 +5,6 @@ import boto3 - """ In lambda handler: diff --git a/parsons/aws/lambda_distribute.py b/parsons/aws/lambda_distribute.py index 850749e5b6..905a4fe2ba 100644 --- a/parsons/aws/lambda_distribute.py +++ b/parsons/aws/lambda_distribute.py @@ -1,15 +1,12 @@ import csv -from io import TextIOWrapper, BytesIO, StringIO import logging import sys -import traceback import time +import traceback +from io import BytesIO, StringIO, TextIOWrapper -from parsons.aws.aws_async import ( - get_func_task_path, - import_and_get_task, - run as maybe_async_run, -) +from parsons.aws.aws_async import get_func_task_path, import_and_get_task +from parsons.aws.aws_async import run as maybe_async_run from parsons.aws.s3 import S3 from parsons.etl.table import Table from parsons.utilities.check_env import check diff --git a/parsons/aws/s3.py b/parsons/aws/s3.py index a1fc472fd1..3568d9cafa 100644 --- a/parsons/aws/s3.py +++ b/parsons/aws/s3.py @@ -1,10 +1,11 @@ +import logging +import os import re + import boto3 from botocore.client import ClientError from parsons.utilities import files -import logging -import os logger = logging.getLogger(__name__) diff --git a/parsons/azure/azure_blob_storage.py b/parsons/azure/azure_blob_storage.py index 1f28572339..c53effc80f 100644 --- a/parsons/azure/azure_blob_storage.py +++ b/parsons/azure/azure_blob_storage.py @@ -4,7 +4,6 @@ from azure.core.exceptions import ResourceNotFoundError from azure.storage.blob import BlobServiceClient, ContentSettings, generate_blob_sas - from parsons.utilities import check_env, files logger = logging.getLogger(__name__) diff --git a/parsons/bill_com/bill_com.py b/parsons/bill_com/bill_com.py index 1b0a411bfd..70455e2485 100644 --- a/parsons/bill_com/bill_com.py +++ b/parsons/bill_com/bill_com.py @@ -1,5 +1,7 @@ -import requests import json + +import requests + from parsons import Table diff --git a/parsons/bloomerang/bloomerang.py b/parsons/bloomerang/bloomerang.py index e90c64b811..82d319afcd 100644 --- a/parsons/bloomerang/bloomerang.py +++ b/parsons/bloomerang/bloomerang.py @@ -1,10 +1,11 @@ import json -import requests import logging +import requests + +from parsons.etl import Table from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector -from parsons.etl import Table logger = logging.getLogger(__name__) diff --git a/parsons/box/box.py b/parsons/box/box.py index 9422fbba08..5a85daeed9 100644 --- a/parsons/box/box.py +++ b/parsons/box/box.py @@ -18,6 +18,7 @@ """ import logging +import tempfile import boxsdk @@ -25,8 +26,6 @@ from parsons.utilities.check_env import check as check_env from parsons.utilities.files import create_temp_file, create_temp_file_for_path -import tempfile - logger = logging.getLogger(__name__) DEFAULT_FOLDER_ID = "0" diff --git a/parsons/braintree/braintree.py b/parsons/braintree/braintree.py index c9d2b08df1..1882a0da9b 100644 --- a/parsons/braintree/braintree.py +++ b/parsons/braintree/braintree.py @@ -1,7 +1,6 @@ import logging import braintree - from parsons.etl.table import Table from parsons.utilities.check_env import check as check_env diff --git a/parsons/capitol_canary/capitol_canary.py b/parsons/capitol_canary/capitol_canary.py index ec0f58d6c8..6cd5509824 100644 --- a/parsons/capitol_canary/capitol_canary.py +++ b/parsons/capitol_canary/capitol_canary.py @@ -1,9 +1,11 @@ +import logging + from requests.auth import HTTPBasicAuth + from parsons.etl import Table from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector from parsons.utilities.datetime import date_to_timestamp -import logging logger = logging.getLogger(__name__) diff --git a/parsons/catalist/catalist.py b/parsons/catalist/catalist.py index a67f017cdb..82f7958fac 100644 --- a/parsons/catalist/catalist.py +++ b/parsons/catalist/catalist.py @@ -9,7 +9,7 @@ import tempfile import time import urllib -from typing import Optional, Union, Dict, List +from typing import Dict, List, Optional, Union from zipfile import ZipFile from parsons.etl import Table diff --git a/parsons/census/census.py b/parsons/census/census.py index 0939ecc749..5798698b53 100644 --- a/parsons/census/census.py +++ b/parsons/census/census.py @@ -1,7 +1,8 @@ import logging -from parsons.utilities.api_connector import APIConnector -from parsons.utilities import check_env + from parsons import Table +from parsons.utilities import check_env +from parsons.utilities.api_connector import APIConnector logger = logging.getLogger(__name__) diff --git a/parsons/community/community.py b/parsons/community/community.py index 4fd68cc982..a327bf78bb 100644 --- a/parsons/community/community.py +++ b/parsons/community/community.py @@ -1,7 +1,8 @@ import logging -from parsons.utilities.api_connector import APIConnector -from parsons.utilities import check_env + from parsons.etl import Table +from parsons.utilities import check_env +from parsons.utilities.api_connector import APIConnector logger = logging.getLogger(__name__) diff --git a/parsons/copper/copper.py b/parsons/copper/copper.py index cf658addc6..1499324969 100644 --- a/parsons/copper/copper.py +++ b/parsons/copper/copper.py @@ -1,10 +1,12 @@ -from requests import request -import math import json +import logging +import math import time + +from requests import request + from parsons.etl import Table from parsons.utilities import check_env -import logging logger = logging.getLogger(__name__) diff --git a/parsons/crowdtangle/crowdtangle.py b/parsons/crowdtangle/crowdtangle.py index 03b4d9352b..38ee78a21b 100644 --- a/parsons/crowdtangle/crowdtangle.py +++ b/parsons/crowdtangle/crowdtangle.py @@ -1,8 +1,10 @@ -from requests import request +import logging import time + +from requests import request + from parsons.etl import Table from parsons.utilities import check_env -import logging logger = logging.getLogger(__name__) diff --git a/parsons/databases/alchemy.py b/parsons/databases/alchemy.py index 43729c3a52..c0e4541f29 100644 --- a/parsons/databases/alchemy.py +++ b/parsons/databases/alchemy.py @@ -1,6 +1,7 @@ -from sqlalchemy import create_engine, Table, MetaData import logging +from sqlalchemy import MetaData, Table, create_engine + logger = logging.getLogger(__name__) diff --git a/parsons/databases/database/database.py b/parsons/databases/database/database.py index 843d375c49..582b918108 100644 --- a/parsons/databases/database/database.py +++ b/parsons/databases/database/database.py @@ -1,6 +1,7 @@ -import parsons.databases.database.constants as consts import logging +import parsons.databases.database.constants as consts + logger = logging.getLogger(__name__) diff --git a/parsons/databases/database_connector.py b/parsons/databases/database_connector.py index e6778846be..de0ee7af2a 100644 --- a/parsons/databases/database_connector.py +++ b/parsons/databases/database_connector.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod from typing import Optional + from parsons.etl.table import Table diff --git a/parsons/databases/discover_database.py b/parsons/databases/discover_database.py index ee66fb6f76..dbb05b9e03 100644 --- a/parsons/databases/discover_database.py +++ b/parsons/databases/discover_database.py @@ -1,10 +1,10 @@ import os -from typing import Optional, Union, Type, List +from typing import List, Optional, Type, Union from parsons.databases.database_connector import DatabaseConnector -from parsons.databases.redshift import Redshift from parsons.databases.mysql import MySQL from parsons.databases.postgres import Postgres +from parsons.databases.redshift import Redshift from parsons.google.google_bigquery import GoogleBigQuery as BigQuery diff --git a/parsons/databases/mysql/create_table.py b/parsons/databases/mysql/create_table.py index 438a249714..9b0f38b8cd 100644 --- a/parsons/databases/mysql/create_table.py +++ b/parsons/databases/mysql/create_table.py @@ -1,8 +1,9 @@ -from parsons.databases.database.database import DatabaseCreateStatement -import parsons.databases.mysql.constants as consts +import logging import petl -import logging + +import parsons.databases.mysql.constants as consts +from parsons.databases.database.database import DatabaseCreateStatement logger = logging.getLogger(__name__) diff --git a/parsons/databases/mysql/mysql.py b/parsons/databases/mysql/mysql.py index d3dddd0627..1f46d1557f 100644 --- a/parsons/databases/mysql/mysql.py +++ b/parsons/databases/mysql/mysql.py @@ -1,16 +1,17 @@ -from parsons import Table -from parsons.utilities import check_env -import petl -import mysql.connector as mysql -from contextlib import contextmanager -from parsons.utilities import files -import pickle import logging import os +import pickle +from contextlib import contextmanager + +import mysql.connector as mysql +import petl + +from parsons import Table +from parsons.databases.alchemy import Alchemy from parsons.databases.database_connector import DatabaseConnector -from parsons.databases.table import BaseTable from parsons.databases.mysql.create_table import MySQLCreateTable -from parsons.databases.alchemy import Alchemy +from parsons.databases.table import BaseTable +from parsons.utilities import check_env, files # Max number of rows that we query at a time, so we can avoid loading huge # data sets into memory. diff --git a/parsons/databases/postgres/postgres.py b/parsons/databases/postgres/postgres.py index fc1c8c1642..df8217a5c5 100644 --- a/parsons/databases/postgres/postgres.py +++ b/parsons/databases/postgres/postgres.py @@ -1,11 +1,11 @@ -from parsons.databases.postgres.postgres_core import PostgresCore -from parsons.databases.table import BaseTable -from parsons.databases.alchemy import Alchemy -from parsons.databases.database_connector import DatabaseConnector -from parsons.etl.table import Table import logging import os +from parsons.databases.alchemy import Alchemy +from parsons.databases.database_connector import DatabaseConnector +from parsons.databases.postgres.postgres_core import PostgresCore +from parsons.databases.table import BaseTable +from parsons.etl.table import Table logger = logging.getLogger(__name__) diff --git a/parsons/databases/postgres/postgres_core.py b/parsons/databases/postgres/postgres_core.py index 080b35a4a9..e6b93eb726 100644 --- a/parsons/databases/postgres/postgres_core.py +++ b/parsons/databases/postgres/postgres_core.py @@ -1,13 +1,15 @@ +import logging +import pickle from contextlib import contextmanager from typing import Optional + +import petl import psycopg2 import psycopg2.extras + +from parsons.databases.postgres.postgres_create_statement import PostgresCreateStatement from parsons.etl.table import Table from parsons.utilities import files -import pickle -import petl -import logging -from parsons.databases.postgres.postgres_create_statement import PostgresCreateStatement # Max number of rows that we query at a time, so we can avoid loading huge # data sets into memory. diff --git a/parsons/databases/postgres/postgres_create_statement.py b/parsons/databases/postgres/postgres_create_statement.py index df3a5a756a..b312349376 100644 --- a/parsons/databases/postgres/postgres_create_statement.py +++ b/parsons/databases/postgres/postgres_create_statement.py @@ -1,8 +1,9 @@ -from parsons.databases.database.database import DatabaseCreateStatement -import parsons.databases.postgres.constants as consts +import logging import petl -import logging + +import parsons.databases.postgres.constants as consts +from parsons.databases.database.database import DatabaseCreateStatement logger = logging.getLogger(__name__) diff --git a/parsons/databases/redshift/redshift.py b/parsons/databases/redshift/redshift.py index 8053c90dbc..d1401f59f6 100644 --- a/parsons/databases/redshift/redshift.py +++ b/parsons/databases/redshift/redshift.py @@ -1,23 +1,25 @@ +import datetime +import json +import logging +import os +import pickle +import random +from contextlib import contextmanager from typing import List, Optional -from parsons.etl.table import Table + +import petl +import psycopg2 +import psycopg2.extras + +from parsons.databases.alchemy import Alchemy +from parsons.databases.database_connector import DatabaseConnector from parsons.databases.redshift.rs_copy_table import RedshiftCopyTable from parsons.databases.redshift.rs_create_table import RedshiftCreateTable -from parsons.databases.redshift.rs_table_utilities import RedshiftTableUtilities from parsons.databases.redshift.rs_schema import RedshiftSchema +from parsons.databases.redshift.rs_table_utilities import RedshiftTableUtilities from parsons.databases.table import BaseTable -from parsons.databases.alchemy import Alchemy +from parsons.etl.table import Table from parsons.utilities import files, sql_helpers -from parsons.databases.database_connector import DatabaseConnector -import psycopg2 -import psycopg2.extras -import os -import logging -import json -import pickle -import petl -from contextlib import contextmanager -import datetime -import random # Max number of rows that we query at a time, so we can avoid loading huge # data sets into memory. diff --git a/parsons/databases/redshift/rs_copy_table.py b/parsons/databases/redshift/rs_copy_table.py index a53bb229ee..a545bac507 100644 --- a/parsons/databases/redshift/rs_copy_table.py +++ b/parsons/databases/redshift/rs_copy_table.py @@ -1,7 +1,8 @@ +import logging import os -from parsons.aws.s3 import S3 import time -import logging + +from parsons.aws.s3 import S3 logger = logging.getLogger(__name__) diff --git a/parsons/databases/redshift/rs_create_table.py b/parsons/databases/redshift/rs_create_table.py index cce1894bdb..119412e2e0 100644 --- a/parsons/databases/redshift/rs_create_table.py +++ b/parsons/databases/redshift/rs_create_table.py @@ -1,8 +1,9 @@ -from parsons.databases.database.database import DatabaseCreateStatement -import parsons.databases.redshift.constants as consts +import logging import petl -import logging + +import parsons.databases.redshift.constants as consts +from parsons.databases.database.database import DatabaseCreateStatement logger = logging.getLogger(__name__) diff --git a/parsons/donorbox/donorbox.py b/parsons/donorbox/donorbox.py index f35ae55295..eac983505d 100644 --- a/parsons/donorbox/donorbox.py +++ b/parsons/donorbox/donorbox.py @@ -1,9 +1,9 @@ -from parsons.utilities.api_connector import APIConnector -from parsons.utilities import check_env -from parsons import Table - -import logging import datetime +import logging + +from parsons import Table +from parsons.utilities import check_env +from parsons.utilities.api_connector import APIConnector logger = logging.getLogger(__name__) diff --git a/parsons/etl/__init__.py b/parsons/etl/__init__.py index 59e433f2ea..0a97b527a3 100644 --- a/parsons/etl/__init__.py +++ b/parsons/etl/__init__.py @@ -1,5 +1,5 @@ +from parsons.etl.etl import ETL from parsons.etl.table import Table from parsons.etl.tofrom import ToFrom -from parsons.etl.etl import ETL __all__ = ["ETL", "Table", "ToFrom"] diff --git a/parsons/etl/tofrom.py b/parsons/etl/tofrom.py index ed04521ecb..92c9e5b1b4 100644 --- a/parsons/etl/tofrom.py +++ b/parsons/etl/tofrom.py @@ -1,8 +1,10 @@ -import petl -import json -import io import gzip +import io +import json from typing import Optional + +import petl + from parsons.utilities import files, zip_archive diff --git a/parsons/facebook_ads/facebook_ads.py b/parsons/facebook_ads/facebook_ads.py index 3ca54dd6f8..bbbfa76fa0 100644 --- a/parsons/facebook_ads/facebook_ads.py +++ b/parsons/facebook_ads/facebook_ads.py @@ -1,11 +1,13 @@ -import os import collections import copy import logging -from joblib import Parallel, delayed -from facebook_business.api import FacebookAdsApi +import os + from facebook_business.adobjects.adaccount import AdAccount from facebook_business.adobjects.customaudience import CustomAudience +from facebook_business.api import FacebookAdsApi +from joblib import Parallel, delayed + from parsons.etl.table import Table logger = logging.getLogger(__name__) diff --git a/parsons/freshdesk/freshdesk.py b/parsons/freshdesk/freshdesk.py index 5bd5c8acd1..1acaccd8a8 100644 --- a/parsons/freshdesk/freshdesk.py +++ b/parsons/freshdesk/freshdesk.py @@ -1,8 +1,9 @@ -from parsons.utilities import check_env -from parsons.utilities.api_connector import APIConnector +import logging import re + from parsons.etl import Table -import logging +from parsons.utilities import check_env +from parsons.utilities.api_connector import APIConnector logger = logging.getLogger(__name__) diff --git a/parsons/geocode/census_geocoder.py b/parsons/geocode/census_geocoder.py index 43075837e2..f914b77aab 100644 --- a/parsons/geocode/census_geocoder.py +++ b/parsons/geocode/census_geocoder.py @@ -1,8 +1,10 @@ -from parsons.etl import Table -import petl -import censusgeocode import logging +import censusgeocode +import petl + +from parsons.etl import Table + logger = logging.getLogger(__name__) diff --git a/parsons/github/github.py b/parsons/github/github.py index 5be0caa004..c703d5918a 100644 --- a/parsons/github/github.py +++ b/parsons/github/github.py @@ -3,9 +3,9 @@ import petl import requests + from github import Github as PyGithub from github.GithubException import UnknownObjectException - from parsons.etl.table import Table from parsons.utilities import check_env, files diff --git a/parsons/google/google_admin.py b/parsons/google/google_admin.py index b69cd5b3d9..951d86bb20 100644 --- a/parsons/google/google_admin.py +++ b/parsons/google/google_admin.py @@ -1,7 +1,6 @@ import uuid from google.auth.transport.requests import AuthorizedSession - from parsons.etl.table import Table from parsons.google.utilities import ( load_google_application_credentials, diff --git a/parsons/google/google_bigquery.py b/parsons/google/google_bigquery.py index 93e78a474a..68f9c0258c 100644 --- a/parsons/google/google_bigquery.py +++ b/parsons/google/google_bigquery.py @@ -6,13 +6,13 @@ from contextlib import contextmanager from typing import List, Optional, Union -import google import petl + +import google from google.cloud import bigquery, exceptions from google.cloud.bigquery import dbapi from google.cloud.bigquery.job import LoadJobConfig from google.oauth2.credentials import Credentials - from parsons.databases.database_connector import DatabaseConnector from parsons.databases.table import BaseTable from parsons.etl import Table diff --git a/parsons/google/google_civic.py b/parsons/google/google_civic.py index 18f2ed4fb3..10997f731c 100644 --- a/parsons/google/google_civic.py +++ b/parsons/google/google_civic.py @@ -1,6 +1,7 @@ -from parsons.utilities import check_env import requests + from parsons.etl import Table +from parsons.utilities import check_env URI = "https://www.googleapis.com/civicinfo/v2/" diff --git a/parsons/google/google_cloud_storage.py b/parsons/google/google_cloud_storage.py index e92d47572e..31a9658029 100644 --- a/parsons/google/google_cloud_storage.py +++ b/parsons/google/google_cloud_storage.py @@ -1,15 +1,15 @@ import datetime import gzip -import petl import logging import time import uuid import zipfile from typing import Optional +import petl + import google from google.cloud import storage, storage_transfer - from parsons.google.utilities import ( load_google_application_credentials, setup_google_application_credentials, diff --git a/parsons/google/google_sheets.py b/parsons/google/google_sheets.py index 0623f9085d..b4c64926b4 100644 --- a/parsons/google/google_sheets.py +++ b/parsons/google/google_sheets.py @@ -5,9 +5,9 @@ from parsons.etl.table import Table from parsons.google.utilities import ( + hexavigesimal, load_google_application_credentials, setup_google_application_credentials, - hexavigesimal, ) logger = logging.getLogger(__name__) diff --git a/parsons/google/utilities.py b/parsons/google/utilities.py index d2a9730d65..9ffc9f4765 100644 --- a/parsons/google/utilities.py +++ b/parsons/google/utilities.py @@ -4,7 +4,6 @@ import google from google.oauth2 import service_account - from parsons.utilities import check_env, files diff --git a/parsons/hustle/hustle.py b/parsons/hustle/hustle.py index e83f0e7121..b7ce5fd68b 100644 --- a/parsons/hustle/hustle.py +++ b/parsons/hustle/hustle.py @@ -1,10 +1,12 @@ -from parsons.etl import Table -from requests import request -from parsons.utilities import check_env, json_format import datetime -from parsons.hustle.column_map import LEAD_COLUMN_MAP import logging +from requests import request + +from parsons.etl import Table +from parsons.hustle.column_map import LEAD_COLUMN_MAP +from parsons.utilities import check_env, json_format + logger = logging.getLogger(__name__) HUSTLE_URI = "https://api.hustle.com/v1/" diff --git a/parsons/mailchimp/mailchimp.py b/parsons/mailchimp/mailchimp.py index ee37462e76..abd3024e70 100644 --- a/parsons/mailchimp/mailchimp.py +++ b/parsons/mailchimp/mailchimp.py @@ -1,5 +1,6 @@ import logging import re + from parsons.etl import Table from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector diff --git a/parsons/mobilecommons/mobilecommons.py b/parsons/mobilecommons/mobilecommons.py index 216dca8e63..d4abd55c10 100644 --- a/parsons/mobilecommons/mobilecommons.py +++ b/parsons/mobilecommons/mobilecommons.py @@ -1,11 +1,13 @@ +import logging + +import xmltodict +from bs4 import BeautifulSoup +from requests import HTTPError + +from parsons import Table from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector from parsons.utilities.datetime import parse_date -from parsons import Table -from bs4 import BeautifulSoup -from requests import HTTPError -import xmltodict -import logging logger = logging.getLogger(__name__) diff --git a/parsons/mobilize_america/ma.py b/parsons/mobilize_america/ma.py index 7c42441a22..ce947ed0d7 100644 --- a/parsons/mobilize_america/ma.py +++ b/parsons/mobilize_america/ma.py @@ -1,11 +1,13 @@ +import collections.abc +import logging +import os +import re + +import petl from requests import request as _request + from parsons.etl.table import Table from parsons.utilities.datetime import date_to_timestamp -import petl -import re -import os -import logging -import collections.abc logger = logging.getLogger(__name__) diff --git a/parsons/newmode/newmode.py b/parsons/newmode/newmode.py index 7b342528f5..bf5d6d90f3 100644 --- a/parsons/newmode/newmode.py +++ b/parsons/newmode/newmode.py @@ -1,7 +1,9 @@ +import logging + from Newmode import Client -from parsons.utilities import check_env + from parsons.etl import Table -import logging +from parsons.utilities import check_env logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/activist_codes.py b/parsons/ngpvan/activist_codes.py index b94558e0c7..cfee2d7789 100644 --- a/parsons/ngpvan/activist_codes.py +++ b/parsons/ngpvan/activist_codes.py @@ -1,8 +1,9 @@ """NGPVAN Activist Code Endpoints""" +import logging + from parsons.etl.table import Table from parsons.ngpvan.utilities import action_parse -import logging logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/bulk_import.py b/parsons/ngpvan/bulk_import.py index 10e73a01c9..242990809a 100644 --- a/parsons/ngpvan/bulk_import.py +++ b/parsons/ngpvan/bulk_import.py @@ -1,11 +1,11 @@ """NGPVAN Bulk Import Endpoints""" -from parsons.etl.table import Table -from parsons.utilities import cloud_storage - +import csv import logging import uuid -import csv + +from parsons.etl.table import Table +from parsons.utilities import cloud_storage logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/canvass_responses.py b/parsons/ngpvan/canvass_responses.py index 4ece6748fa..f4356b7197 100644 --- a/parsons/ngpvan/canvass_responses.py +++ b/parsons/ngpvan/canvass_responses.py @@ -1,8 +1,9 @@ """NGPVAN Canvass Responses Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/changed_entities.py b/parsons/ngpvan/changed_entities.py index 457bb6530a..e0ee9ed5eb 100644 --- a/parsons/ngpvan/changed_entities.py +++ b/parsons/ngpvan/changed_entities.py @@ -1,9 +1,10 @@ """NGPVAN Changed Entities""" -from parsons.etl.table import Table import logging import time +from parsons.etl.table import Table + logger = logging.getLogger(__name__) RETRY_RATE = 10 diff --git a/parsons/ngpvan/codes.py b/parsons/ngpvan/codes.py index 27bcac51c6..7d5d7bb6d2 100644 --- a/parsons/ngpvan/codes.py +++ b/parsons/ngpvan/codes.py @@ -1,8 +1,9 @@ """NGPVAN Code Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/contact_notes.py b/parsons/ngpvan/contact_notes.py index 11f543b9a5..68af19c0ce 100644 --- a/parsons/ngpvan/contact_notes.py +++ b/parsons/ngpvan/contact_notes.py @@ -1,8 +1,9 @@ """NGPVAN Contact Notes Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/custom_fields.py b/parsons/ngpvan/custom_fields.py index 910289e4d8..cf4d6d6cfc 100644 --- a/parsons/ngpvan/custom_fields.py +++ b/parsons/ngpvan/custom_fields.py @@ -1,6 +1,7 @@ -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/email.py b/parsons/ngpvan/email.py index 091510f253..f17b39b2c3 100644 --- a/parsons/ngpvan/email.py +++ b/parsons/ngpvan/email.py @@ -1,6 +1,7 @@ -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/locations.py b/parsons/ngpvan/locations.py index e05b5dacb2..6518eece5f 100644 --- a/parsons/ngpvan/locations.py +++ b/parsons/ngpvan/locations.py @@ -1,8 +1,9 @@ """NGPVAN Locations Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/people.py b/parsons/ngpvan/people.py index 7fd84c455b..a0a5ec5a25 100644 --- a/parsons/ngpvan/people.py +++ b/parsons/ngpvan/people.py @@ -1,6 +1,7 @@ -from parsons.utilities import json_format -from typing import Union, List, Dict import logging +from typing import Dict, List, Union + +from parsons.utilities import json_format logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/printed_lists.py b/parsons/ngpvan/printed_lists.py index a7fe0b6805..6152e2e4cf 100644 --- a/parsons/ngpvan/printed_lists.py +++ b/parsons/ngpvan/printed_lists.py @@ -1,8 +1,9 @@ """NGPVAN Saved List Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/saved_lists.py b/parsons/ngpvan/saved_lists.py index 9f7156cf91..77c989df99 100644 --- a/parsons/ngpvan/saved_lists.py +++ b/parsons/ngpvan/saved_lists.py @@ -1,11 +1,13 @@ """NGPVAN Saved List Endpoints""" -from parsons.etl.table import Table -from parsons.utilities import cloud_storage import logging import uuid + from suds.client import Client +from parsons.etl.table import Table +from parsons.utilities import cloud_storage + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/scores.py b/parsons/ngpvan/scores.py index 35b58e00c9..2ea01aa97f 100644 --- a/parsons/ngpvan/scores.py +++ b/parsons/ngpvan/scores.py @@ -1,11 +1,13 @@ """NGPVAN Score Endpoints""" -from parsons.etl.table import Table -from parsons.utilities import cloud_storage -import uuid import logging +import uuid + import petl +from parsons.etl.table import Table +from parsons.utilities import cloud_storage + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/signups.py b/parsons/ngpvan/signups.py index 302dbc70e4..32b28cedb9 100644 --- a/parsons/ngpvan/signups.py +++ b/parsons/ngpvan/signups.py @@ -1,8 +1,9 @@ """NGPVAN Signups Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/supporter_groups.py b/parsons/ngpvan/supporter_groups.py index 6d50ac9dce..be68e2dad7 100644 --- a/parsons/ngpvan/supporter_groups.py +++ b/parsons/ngpvan/supporter_groups.py @@ -1,8 +1,9 @@ """NGPVAN Supporter Groups Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/survey_questions.py b/parsons/ngpvan/survey_questions.py index c6856a82fe..c1e8252f6f 100644 --- a/parsons/ngpvan/survey_questions.py +++ b/parsons/ngpvan/survey_questions.py @@ -1,8 +1,9 @@ """NGPVAN Survey Questions Endpoints""" -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/targets.py b/parsons/ngpvan/targets.py index 78f78f5a9a..a5630ee732 100644 --- a/parsons/ngpvan/targets.py +++ b/parsons/ngpvan/targets.py @@ -1,9 +1,11 @@ """NGPVAN Target Endpoints""" -from parsons.etl.table import Table import logging + import petl +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/van.py b/parsons/ngpvan/van.py index 18a5dcdfc9..018bf63129 100644 --- a/parsons/ngpvan/van.py +++ b/parsons/ngpvan/van.py @@ -1,23 +1,24 @@ import logging -from parsons.ngpvan.events import Events -from parsons.ngpvan.email import Email -from parsons.ngpvan.van_connector import VANConnector -from parsons.ngpvan.people import People -from parsons.ngpvan.saved_lists import SavedLists, Folders, ExportJobs + from parsons.ngpvan.activist_codes import ActivistCodes -from parsons.ngpvan.canvass_responses import CanvassResponses -from parsons.ngpvan.survey_questions import SurveyQuestions -from parsons.ngpvan.supporter_groups import SupporterGroups -from parsons.ngpvan.codes import Codes -from parsons.ngpvan.scores import Scores, FileLoadingJobs -from parsons.ngpvan.signups import Signups -from parsons.ngpvan.locations import Locations from parsons.ngpvan.bulk_import import BulkImport +from parsons.ngpvan.canvass_responses import CanvassResponses from parsons.ngpvan.changed_entities import ChangedEntities +from parsons.ngpvan.codes import Codes from parsons.ngpvan.contact_notes import ContactNotes from parsons.ngpvan.custom_fields import CustomFields -from parsons.ngpvan.targets import Targets +from parsons.ngpvan.email import Email +from parsons.ngpvan.events import Events +from parsons.ngpvan.locations import Locations +from parsons.ngpvan.people import People from parsons.ngpvan.printed_lists import PrintedLists +from parsons.ngpvan.saved_lists import ExportJobs, Folders, SavedLists +from parsons.ngpvan.scores import FileLoadingJobs, Scores +from parsons.ngpvan.signups import Signups +from parsons.ngpvan.supporter_groups import SupporterGroups +from parsons.ngpvan.survey_questions import SurveyQuestions +from parsons.ngpvan.targets import Targets +from parsons.ngpvan.van_connector import VANConnector logger = logging.getLogger(__name__) diff --git a/parsons/ngpvan/van_connector.py b/parsons/ngpvan/van_connector.py index c7e7de98c3..f9937ee69d 100644 --- a/parsons/ngpvan/van_connector.py +++ b/parsons/ngpvan/van_connector.py @@ -1,5 +1,7 @@ -from suds.client import Client import logging + +from suds.client import Client + from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector diff --git a/parsons/notifications/gmail.py b/parsons/notifications/gmail.py index e613cc0b39..d988054502 100644 --- a/parsons/notifications/gmail.py +++ b/parsons/notifications/gmail.py @@ -1,8 +1,10 @@ import base64 -from googleapiclient.errors import HttpError + from googleapiclient.discovery import build +from googleapiclient.errors import HttpError from httplib2 import Http -from oauth2client import file, client, tools +from oauth2client import client, file, tools + from parsons.notifications.sendmail import SendMail SCOPES = "https://www.googleapis.com/auth/gmail.send" diff --git a/parsons/notifications/sendmail.py b/parsons/notifications/sendmail.py index f228f99c23..553e5e9efb 100644 --- a/parsons/notifications/sendmail.py +++ b/parsons/notifications/sendmail.py @@ -1,18 +1,19 @@ # Adapted from Gmail API tutorial https://developers.google.com/gmail/api +import io +import logging +import mimetypes +import os from abc import ABC, abstractmethod -from email.mime.text import MIMEText -from email.mime.multipart import MIMEMultipart -from email.mime.image import MIMEImage +from email.encoders import encode_base64 +from email.mime.application import MIMEApplication from email.mime.audio import MIMEAudio from email.mime.base import MIMEBase -from email.mime.application import MIMEApplication -from email.encoders import encode_base64 +from email.mime.image import MIMEImage +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText from email.utils import parseaddr + from validate_email import validate_email -import io -import logging -import mimetypes -import os # BUG: can't send files equal to or larger than 6MB # There is a possible fix diff --git a/parsons/notifications/slack.py b/parsons/notifications/slack.py index b931fc6ddf..02ab6f4188 100644 --- a/parsons/notifications/slack.py +++ b/parsons/notifications/slack.py @@ -2,13 +2,12 @@ import time import warnings -from parsons.etl.table import Table -from parsons.utilities.check_env import check - +import requests from slackclient import SlackClient from slackclient.exceptions import SlackClientError -import requests +from parsons.etl.table import Table +from parsons.utilities.check_env import check class Slack(object): diff --git a/parsons/pdi/flags.py b/parsons/pdi/flags.py index 8cab60bd1a..82ad36c438 100644 --- a/parsons/pdi/flags.py +++ b/parsons/pdi/flags.py @@ -1,6 +1,7 @@ -from dateutil.parser import parse from datetime import datetime +from dateutil.parser import parse + class Flags: """A class to access the Flags PDI API endpoint.""" diff --git a/parsons/pdi/pdi.py b/parsons/pdi/pdi.py index b1f197d220..98826f759a 100644 --- a/parsons/pdi/pdi.py +++ b/parsons/pdi/pdi.py @@ -1,22 +1,21 @@ -from parsons.pdi.flag_ids import FlagIDs -from parsons.pdi.flags import Flags -from parsons.pdi.universes import Universes -from parsons.pdi.questions import Questions -from parsons.pdi.acquisition_types import AcquisitionTypes -from parsons.pdi.events import Events -from parsons.pdi.locations import Locations -from parsons.pdi.contacts import Contacts -from parsons.pdi.activities import Activities - -from parsons import Table -from parsons.utilities import check_env - +import logging from datetime import datetime, timezone -from dateutil.parser import parse from json.decoder import JSONDecodeError -import logging + import requests +from dateutil.parser import parse +from parsons import Table +from parsons.pdi.acquisition_types import AcquisitionTypes +from parsons.pdi.activities import Activities +from parsons.pdi.contacts import Contacts +from parsons.pdi.events import Events +from parsons.pdi.flag_ids import FlagIDs +from parsons.pdi.flags import Flags +from parsons.pdi.locations import Locations +from parsons.pdi.questions import Questions +from parsons.pdi.universes import Universes +from parsons.utilities import check_env logger = logging.getLogger(__name__) diff --git a/parsons/phone2action/p2a.py b/parsons/phone2action/p2a.py index 6c02250acb..8c04283a61 100644 --- a/parsons/phone2action/p2a.py +++ b/parsons/phone2action/p2a.py @@ -1,6 +1,7 @@ -from parsons.capitol_canary import CapitolCanary import logging +from parsons.capitol_canary import CapitolCanary + logger = logging.getLogger(__name__) diff --git a/parsons/quickbase/quickbase.py b/parsons/quickbase/quickbase.py index c2f8c50d7b..066c1155d3 100644 --- a/parsons/quickbase/quickbase.py +++ b/parsons/quickbase/quickbase.py @@ -1,9 +1,9 @@ import logging + from parsons.etl.table import Table from parsons.utilities import check_env from parsons.utilities.api_connector import APIConnector - logger = logging.getLogger(__name__) diff --git a/parsons/redash/redash.py b/parsons/redash/redash.py index f00d065334..aae1420241 100644 --- a/parsons/redash/redash.py +++ b/parsons/redash/redash.py @@ -1,8 +1,9 @@ import json import logging -import requests import time +import requests + from parsons.etl.table import Table from parsons.utilities.check_env import check diff --git a/parsons/rockthevote/rtv.py b/parsons/rockthevote/rtv.py index baa14da966..ccbe5561aa 100644 --- a/parsons/rockthevote/rtv.py +++ b/parsons/rockthevote/rtv.py @@ -1,10 +1,10 @@ import datetime import logging -import petl import re -import requests import time +import petl +import requests from dateutil.parser import parse as parse_date from parsons import Table diff --git a/parsons/salesforce/salesforce.py b/parsons/salesforce/salesforce.py index c2ac407a42..e9e4b390f1 100644 --- a/parsons/salesforce/salesforce.py +++ b/parsons/salesforce/salesforce.py @@ -1,7 +1,9 @@ +import json +import logging + from simple_salesforce import Salesforce as _Salesforce + from parsons.utilities import check_env -import logging -import json logger = logging.getLogger(__name__) diff --git a/parsons/scytl/scytl.py b/parsons/scytl/scytl.py index 0df28ba079..84b015d8cf 100644 --- a/parsons/scytl/scytl.py +++ b/parsons/scytl/scytl.py @@ -1,13 +1,14 @@ -import zipfile import csv -import requests -import xml.etree.ElementTree as ET import typing as t +import xml.etree.ElementTree as ET +import zipfile +from dataclasses import dataclass from datetime import datetime +from io import BytesIO, StringIO + +import requests from dateutil.parser import parse as parsedate from pytz import timezone -from io import BytesIO, StringIO -from dataclasses import dataclass CLARITY_URL = "https://results.enr.clarityelections.com/" diff --git a/parsons/sftp/utilities.py b/parsons/sftp/utilities.py index 999a4839e6..bbd2540930 100644 --- a/parsons/sftp/utilities.py +++ b/parsons/sftp/utilities.py @@ -1,4 +1,5 @@ from functools import wraps + import paramiko diff --git a/parsons/shopify/shopify.py b/parsons/shopify/shopify.py index d6a18e15ab..4e63b5bf1a 100644 --- a/parsons/shopify/shopify.py +++ b/parsons/shopify/shopify.py @@ -1,5 +1,5 @@ -from datetime import datetime, timedelta import re +from datetime import datetime, timedelta from parsons.etl.table import Table from parsons.utilities import check_env diff --git a/parsons/targetsmart/targetsmart_api.py b/parsons/targetsmart/targetsmart_api.py index c4f37a8f4f..c63055ee70 100644 --- a/parsons/targetsmart/targetsmart_api.py +++ b/parsons/targetsmart/targetsmart_api.py @@ -8,6 +8,7 @@ import petl import requests + from parsons.etl.table import Table from parsons.utilities import check_env diff --git a/parsons/targetsmart/targetsmart_automation.py b/parsons/targetsmart/targetsmart_automation.py index b23273cd97..9897d62558 100644 --- a/parsons/targetsmart/targetsmart_automation.py +++ b/parsons/targetsmart/targetsmart_automation.py @@ -21,16 +21,17 @@ """ -from parsons.sftp.sftp import SFTP -from parsons.etl.table import Table -from parsons.utilities.files import create_temp_file -from parsons.utilities import check_env -import xml.etree.ElementTree as ET -import uuid -import time import logging +import time +import uuid +import xml.etree.ElementTree as ET + import xmltodict +from parsons.etl.table import Table +from parsons.sftp.sftp import SFTP +from parsons.utilities import check_env +from parsons.utilities.files import create_temp_file TS_STFP_HOST = "transfer.targetsmart.com" TS_SFTP_PORT = 22 diff --git a/parsons/tools/credential_tools.py b/parsons/tools/credential_tools.py index 056723cebe..33b164c519 100644 --- a/parsons/tools/credential_tools.py +++ b/parsons/tools/credential_tools.py @@ -1,7 +1,8 @@ -from base64 import b64encode, b64decode -import click import json import os +from base64 import b64decode, b64encode + +import click PREFIX = "PRSNSENV" diff --git a/parsons/turbovote/turbovote.py b/parsons/turbovote/turbovote.py index 55db0b7ccc..3bbec8446a 100644 --- a/parsons/turbovote/turbovote.py +++ b/parsons/turbovote/turbovote.py @@ -1,6 +1,8 @@ -from parsons.etl import Table -import requests import logging + +import requests + +from parsons.etl import Table from parsons.utilities import check_env logger = logging.getLogger(__name__) diff --git a/parsons/twilio/twilio.py b/parsons/twilio/twilio.py index 8a68eec29e..f6818de4ac 100644 --- a/parsons/twilio/twilio.py +++ b/parsons/twilio/twilio.py @@ -1,8 +1,8 @@ -from twilio.rest import Client -from parsons.utilities import check_env, json_format -from parsons.etl import Table import logging +from parsons.etl import Table +from parsons.utilities import check_env, json_format +from twilio.rest import Client logger = logging.getLogger(__name__) diff --git a/parsons/utilities/api_connector.py b/parsons/utilities/api_connector.py index 39564cc20b..2a0d5aab4f 100644 --- a/parsons/utilities/api_connector.py +++ b/parsons/utilities/api_connector.py @@ -1,7 +1,8 @@ -from requests import request as _request -from requests.exceptions import HTTPError import logging import urllib.parse + +from requests import request as _request +from requests.exceptions import HTTPError from simplejson.errors import JSONDecodeError logger = logging.getLogger(__name__) diff --git a/parsons/utilities/datetime.py b/parsons/utilities/datetime.py index a3ace88700..a402bf0253 100644 --- a/parsons/utilities/datetime.py +++ b/parsons/utilities/datetime.py @@ -1,6 +1,7 @@ -from dateutil.parser import parse import datetime +from dateutil.parser import parse + def date_to_timestamp(value, tzinfo=datetime.timezone.utc): """Convert any date value into a Unix timestamp. diff --git a/parsons/utilities/oauth_api_connector.py b/parsons/utilities/oauth_api_connector.py index d0b006f5b9..621d4dd059 100644 --- a/parsons/utilities/oauth_api_connector.py +++ b/parsons/utilities/oauth_api_connector.py @@ -2,9 +2,10 @@ from typing import Dict, Optional from oauthlib.oauth2 import BackendApplicationClient -from parsons.utilities.api_connector import APIConnector from requests_oauthlib import OAuth2Session +from parsons.utilities.api_connector import APIConnector + class OAuth2APIConnector(APIConnector): """ diff --git a/parsons/utilities/ssh_utilities.py b/parsons/utilities/ssh_utilities.py index d8466fb91d..52327f149d 100644 --- a/parsons/utilities/ssh_utilities.py +++ b/parsons/utilities/ssh_utilities.py @@ -1,6 +1,7 @@ import logging -import sshtunnel + import psycopg2 +import sshtunnel def query_through_ssh( diff --git a/parsons/utilities/zip_archive.py b/parsons/utilities/zip_archive.py index 33179e9c32..2d944fedb9 100644 --- a/parsons/utilities/zip_archive.py +++ b/parsons/utilities/zip_archive.py @@ -1,5 +1,6 @@ import os import zipfile + from parsons.utilities.files import create_temp_directory diff --git a/parsons/zoom/zoom.py b/parsons/zoom/zoom.py index 7c71bbe32d..61ff5b401e 100644 --- a/parsons/zoom/zoom.py +++ b/parsons/zoom/zoom.py @@ -1,9 +1,10 @@ -from parsons.utilities import check_env -from parsons.utilities.oauth_api_connector import OAuth2APIConnector -from parsons import Table import logging import uuid +from parsons import Table +from parsons.utilities import check_env +from parsons.utilities.oauth_api_connector import OAuth2APIConnector + logger = logging.getLogger(__name__) ZOOM_URI = "https://api.zoom.us/v2/" diff --git a/setup.py b/setup.py index be049f9518..6043c8ebb8 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ import os from distutils.core import setup from pathlib import Path + from setuptools import find_packages diff --git a/test/fixtures.py b/test/fixtures.py index 346639dd13..efd7ab028b 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -1,6 +1,6 @@ import pytest -from parsons.etl import Table +from parsons.etl import Table """ Simple Table diff --git a/test/test_actblue/test_actblue.py b/test/test_actblue/test_actblue.py index 4d73e07b5c..cbc653fc6f 100644 --- a/test/test_actblue/test_actblue.py +++ b/test/test_actblue/test_actblue.py @@ -1,9 +1,10 @@ import unittest -import requests_mock -from parsons import Table, ActBlue from test.test_actblue import test_columns_data from unittest.mock import MagicMock +import requests_mock + +from parsons import ActBlue, Table TEST_CLIENT_UUID = "someuuid" TEST_CLIENT_SECRET = "somesecret" diff --git a/test/test_action_builder/test_action_builder.py b/test/test_action_builder/test_action_builder.py index d0a71dd2e5..dfc0c3e1fe 100644 --- a/test/test_action_builder/test_action_builder.py +++ b/test/test_action_builder/test_action_builder.py @@ -1,9 +1,11 @@ -import unittest -import requests_mock import json -from parsons import Table, ActionBuilder +import unittest from test.utils import assert_matching_tables +import requests_mock + +from parsons import ActionBuilder, Table + class TestActionBuilder(unittest.TestCase): @requests_mock.Mocker() diff --git a/test/test_action_kit.py b/test/test_action_kit.py index 2da786267f..ec20165162 100644 --- a/test/test_action_kit.py +++ b/test/test_action_kit.py @@ -1,10 +1,10 @@ import json import os import unittest +from test.utils import assert_matching_tables from unittest import mock -from parsons import ActionKit, Table -from test.utils import assert_matching_tables +from parsons import ActionKit, Table ENV_PARAMETERS = { "ACTION_KIT_DOMAIN": "env_domain", diff --git a/test/test_action_network/test_action_network.py b/test/test_action_network/test_action_network.py index 63e18243c7..51b28ade6d 100644 --- a/test/test_action_network/test_action_network.py +++ b/test/test_action_network/test_action_network.py @@ -1,9 +1,11 @@ +import json import unittest +from test.utils import assert_matching_tables + import requests_mock -import json + from parsons import Table from parsons.action_network import ActionNetwork -from test.utils import assert_matching_tables class TestActionNetwork(unittest.TestCase): diff --git a/test/test_airtable/test_airtable.py b/test/test_airtable/test_airtable.py index 349e72b23a..d0f4a00e79 100644 --- a/test/test_airtable/test_airtable.py +++ b/test/test_airtable/test_airtable.py @@ -1,9 +1,10 @@ -import unittest import os -import requests_mock -from parsons import Airtable, Table +import unittest from test.utils import assert_matching_tables + +import requests_mock from airtable_responses import ( + delete_responses, insert_response, insert_responses, records_response, @@ -11,9 +12,9 @@ update_responses, upsert_with_id_responses, upsert_with_key_responses, - delete_responses, ) +from parsons import Airtable, Table os.environ["AIRTABLE_PERSONAL_ACCESS_TOKEN"] = "SOME_TOKEN" BASE_KEY = "BASEKEY" diff --git a/test/test_alchemer/test_getresponses.py b/test/test_alchemer/test_getresponses.py index c529681b0d..711ca7771e 100644 --- a/test/test_alchemer/test_getresponses.py +++ b/test/test_alchemer/test_getresponses.py @@ -1,8 +1,9 @@ +import logging import os import unittest import unittest.mock as mock + from parsons import Alchemer -import logging logger = logging.getLogger(__name__) diff --git a/test/test_alchemer/test_getsurveys.py b/test/test_alchemer/test_getsurveys.py index 62a5044111..d79c06848f 100644 --- a/test/test_alchemer/test_getsurveys.py +++ b/test/test_alchemer/test_getsurveys.py @@ -1,8 +1,9 @@ +import logging import os import unittest import unittest.mock as mock + from parsons import Alchemer -import logging logger = logging.getLogger(__name__) diff --git a/test/test_auth0.py b/test/test_auth0.py index 82ba411cd5..52cd9075de 100644 --- a/test/test_auth0.py +++ b/test/test_auth0.py @@ -5,6 +5,7 @@ from test.utils import assert_matching_tables import requests_mock + from parsons import Auth0, Table CLIENT_ID = "abc" diff --git a/test/test_aws_async.py b/test/test_aws_async.py index 2c005cbe76..c10c9f3214 100644 --- a/test/test_aws_async.py +++ b/test/test_aws_async.py @@ -2,7 +2,7 @@ from test.utils import assert_matching_tables from parsons import Table -from parsons.aws.aws_async import import_and_get_task, get_func_task_path +from parsons.aws.aws_async import get_func_task_path, import_and_get_task from parsons.aws.lambda_distribute import distribute_task diff --git a/test/test_azure/test_azure_blob_storage.py b/test/test_azure/test_azure_blob_storage.py index 1aca09ba9a..3ff0a8a373 100644 --- a/test/test_azure/test_azure_blob_storage.py +++ b/test/test_azure/test_azure_blob_storage.py @@ -4,11 +4,9 @@ from urllib.parse import parse_qs, urlparse from azure.storage.blob import BlobClient, ContainerClient - from parsons import AzureBlobStorage, Table from parsons.utilities import files - TEST_ACCOUNT_NAME = os.getenv("PARSONS_AZURE_ACCOUNT_NAME") TEST_CREDENTIAL = os.getenv("PARSONS_AZURE_CREDENTIAL") TEST_CONTAINER_NAME = os.getenv("PARSONS_AZURE_CONTAINER_NAME") diff --git a/test/test_bill_com/test_bill_com.py b/test/test_bill_com/test_bill_com.py index 8e23969ee5..ae48fc4c22 100644 --- a/test/test_bill_com/test_bill_com.py +++ b/test/test_bill_com/test_bill_com.py @@ -1,9 +1,11 @@ -import unittest -import requests_mock import json -from parsons import Table, BillCom +import unittest from test.utils import assert_matching_tables +import requests_mock + +from parsons import BillCom, Table + class TestBillCom(unittest.TestCase): @requests_mock.Mocker() diff --git a/test/test_bloomerang/test_bloomerang.py b/test/test_bloomerang/test_bloomerang.py index 19491cfeca..f8944016ed 100644 --- a/test/test_bloomerang/test_bloomerang.py +++ b/test/test_bloomerang/test_bloomerang.py @@ -1,24 +1,25 @@ import os import unittest -import requests_mock -from unittest import mock -from test.utils import assert_matching_tables -from parsons import Bloomerang, Table - from test.test_bloomerang.test_data import ( ENV_PARAMETERS, ID, - TEST_DELETE, TEST_CREATE_CONSTITUENT, + TEST_CREATE_INTERACTION, + TEST_CREATE_TRANSACTION, + TEST_DELETE, TEST_GET_CONSTITUENT, TEST_GET_CONSTITUENTS, - TEST_CREATE_TRANSACTION, - TEST_GET_TRANSACTION, - TEST_GET_TRANSACTIONS, - TEST_CREATE_INTERACTION, TEST_GET_INTERACTION, TEST_GET_INTERACTIONS, + TEST_GET_TRANSACTION, + TEST_GET_TRANSACTIONS, ) +from test.utils import assert_matching_tables +from unittest import mock + +import requests_mock + +from parsons import Bloomerang, Table class TestBloomerang(unittest.TestCase): diff --git a/test/test_braintree/test_braintree.py b/test/test_braintree/test_braintree.py index 8696dfa610..42a6a3d9ab 100644 --- a/test/test_braintree/test_braintree.py +++ b/test/test_braintree/test_braintree.py @@ -2,10 +2,11 @@ import decimal import os import unittest -import requests_mock from test.utils import assert_matching_tables -from parsons import Table, Braintree +import requests_mock + +from parsons import Braintree, Table _dir = os.path.dirname(__file__) diff --git a/test/test_capitol_canary.py b/test/test_capitol_canary.py index 08ed046be2..0d8896139c 100644 --- a/test/test_capitol_canary.py +++ b/test/test_capitol_canary.py @@ -1,10 +1,11 @@ +import copy +import os import unittest -import requests_mock from test.utils import validate_list -from parsons import CapitolCanary -import os -import copy +import requests_mock + +from parsons import CapitolCanary adv_json = { "data": [ diff --git a/test/test_catalist/conftest.py b/test/test_catalist/conftest.py index cb9f13cae9..20d91e4d3a 100644 --- a/test/test_catalist/conftest.py +++ b/test/test_catalist/conftest.py @@ -1,8 +1,9 @@ -from unittest.mock import MagicMock +import re from typing import Generator +from unittest.mock import MagicMock + import pytest import requests_mock -import re @pytest.fixture(autouse=True) diff --git a/test/test_catalist/test_catalist.py b/test/test_catalist/test_catalist.py index b6b2a075dc..f9c3cb54f6 100644 --- a/test/test_catalist/test_catalist.py +++ b/test/test_catalist/test_catalist.py @@ -1,8 +1,10 @@ -from parsons import Table, CatalistMatch import time -import pytest from unittest.mock import MagicMock +import pytest + +from parsons import CatalistMatch, Table + TEST_CLIENT_ID = "some_client_id" TEST_CLIENT_SECRET = "some_client_secret" TEST_SFTP_USERNAME = "username" diff --git a/test/test_census/test_census.py b/test/test_census/test_census.py index 795234176e..d243bb5ec7 100644 --- a/test/test_census/test_census.py +++ b/test/test_census/test_census.py @@ -1,7 +1,9 @@ import unittest -import requests_mock from test.utils import mark_live_test -from parsons import Table, Census + +import requests_mock + +from parsons import Census, Table class TestCensus(unittest.TestCase): diff --git a/test/test_civis.py b/test/test_civis.py index a97eb7219e..d2add8df00 100644 --- a/test/test_civis.py +++ b/test/test_civis.py @@ -1,5 +1,6 @@ -import unittest import os +import unittest + from parsons import CivisClient, Table # from . import scratch_creds diff --git a/test/test_community/test_community.py b/test/test_community/test_community.py index 71f2900941..289cb8c293 100644 --- a/test/test_community/test_community.py +++ b/test/test_community/test_community.py @@ -1,7 +1,8 @@ import unittest + import requests_mock -from parsons import Community +from parsons import Community TEST_CLIENT_ID = "someuuid" TEST_CLIENT_TOKEN = "somesecret" diff --git a/test/test_controlshift/test_controlshift.py b/test/test_controlshift/test_controlshift.py index b0484c9275..22396bb70b 100644 --- a/test/test_controlshift/test_controlshift.py +++ b/test/test_controlshift/test_controlshift.py @@ -1,8 +1,10 @@ -import requests_mock -from unittest import TestCase +from test.test_controlshift import test_cs_data as test_data # type: ignore from test.utils import mark_live_test, validate_list +from unittest import TestCase + +import requests_mock + from parsons import Controlshift -from test.test_controlshift import test_cs_data as test_data # type: ignore @mark_live_test diff --git a/test/test_copper/test_copper.py b/test/test_copper/test_copper.py index e4db5c14e0..1c3799f57c 100644 --- a/test/test_copper/test_copper.py +++ b/test/test_copper/test_copper.py @@ -1,11 +1,13 @@ -import unittest -import os import json -import requests_mock +import logging +import os import sys -from parsons import Copper, Table +import unittest from test.utils import assert_matching_tables -import logging + +import requests_mock + +from parsons import Copper, Table # Set up the logger logger = logging.getLogger(__name__) diff --git a/test/test_credential_tools.py b/test/test_credential_tools.py index b3939b2562..3fb2fc7d42 100644 --- a/test/test_credential_tools.py +++ b/test/test_credential_tools.py @@ -1,9 +1,10 @@ -from parsons.tools import credential_tools as ct import json import os import shutil import unittest +from parsons.tools import credential_tools as ct + class TestCredentialTool(unittest.TestCase): def setUp(self): diff --git a/test/test_crowdtangle/test_crowdtangle.py b/test/test_crowdtangle/test_crowdtangle.py index 26f1dbc5d2..897a5fdee8 100644 --- a/test/test_crowdtangle/test_crowdtangle.py +++ b/test/test_crowdtangle/test_crowdtangle.py @@ -1,9 +1,11 @@ import unittest -import requests_mock -from test.utils import assert_matching_tables -from test.test_crowdtangle.post import expected_posts from test.test_crowdtangle.leaderboard import expected_leaderboard from test.test_crowdtangle.link_post import expected_post +from test.test_crowdtangle.post import expected_posts +from test.utils import assert_matching_tables + +import requests_mock + from parsons import CrowdTangle, Table CT_API_KEY = "FAKE_KEY" diff --git a/test/test_databases/fakes.py b/test/test_databases/fakes.py index a76330a2ed..71b183dc0c 100644 --- a/test/test_databases/fakes.py +++ b/test/test_databases/fakes.py @@ -1,6 +1,7 @@ -from parsons.etl.table import Table import logging +from parsons.etl.table import Table + logger = logging.getLogger(__name__) diff --git a/test/test_databases/test_bigquery.py b/test/test_databases/test_bigquery.py index 05e7671ceb..871017b0a6 100644 --- a/test/test_databases/test_bigquery.py +++ b/test/test_databases/test_bigquery.py @@ -5,9 +5,7 @@ from typing import Union from google.cloud import bigquery, exceptions - -from parsons import GoogleBigQuery -from parsons import Table +from parsons import GoogleBigQuery, Table from parsons.google.google_cloud_storage import GoogleCloudStorage diff --git a/test/test_databases/test_database.py b/test/test_databases/test_database.py index c56116e3d1..1763f0f7aa 100644 --- a/test/test_databases/test_database.py +++ b/test/test_databases/test_database.py @@ -1,16 +1,8 @@ -from parsons.databases.database.constants import ( - SMALLINT, - MEDIUMINT, - INT, - BIGINT, - BOOL, - VARCHAR, -) +import pytest +from parsons.databases.database.constants import BIGINT, BOOL, INT, MEDIUMINT, SMALLINT, VARCHAR from parsons.databases.database.database import DatabaseCreateStatement -import pytest - @pytest.fixture def dcs(): diff --git a/test/test_databases/test_dbsync.py b/test/test_databases/test_dbsync.py index c726245481..39311ebc3c 100644 --- a/test/test_databases/test_dbsync.py +++ b/test/test_databases/test_dbsync.py @@ -1,8 +1,9 @@ -from parsons import Postgres, DBSync, Table, Redshift +import os +import unittest from test.test_databases.fakes import FakeDatabase from test.utils import assert_matching_tables -import unittest -import os + +from parsons import DBSync, Postgres, Redshift, Table _dir = os.path.dirname(__file__) diff --git a/test/test_databases/test_discover_database.py b/test/test_databases/test_discover_database.py index 51b4771bf2..d1dabaebb6 100644 --- a/test/test_databases/test_discover_database.py +++ b/test/test_databases/test_discover_database.py @@ -1,10 +1,11 @@ import unittest from unittest.mock import patch -from parsons.databases.redshift import Redshift -from parsons.databases.mysql import MySQL -from parsons.databases.postgres import Postgres + from parsons import GoogleBigQuery as BigQuery from parsons.databases.discover_database import discover_database +from parsons.databases.mysql import MySQL +from parsons.databases.postgres import Postgres +from parsons.databases.redshift import Redshift class TestDiscoverDatabase(unittest.TestCase): diff --git a/test/test_databases/test_mysql.py b/test/test_databases/test_mysql.py index 20220668ed..4a29859a2d 100644 --- a/test/test_databases/test_mysql.py +++ b/test/test_databases/test_mysql.py @@ -1,8 +1,9 @@ +import os +import unittest +from test.utils import assert_matching_tables + from parsons import MySQL, Table from parsons.databases.mysql.create_table import MySQLCreateTable -from test.utils import assert_matching_tables -import unittest -import os # These tests interact directly with the MySQL database. To run, set env variable "LIVE_TEST=True" diff --git a/test/test_databases/test_postgres.py b/test/test_databases/test_postgres.py index 5c8e864c3f..2e669d27b5 100644 --- a/test/test_databases/test_postgres.py +++ b/test/test_databases/test_postgres.py @@ -1,7 +1,8 @@ -from parsons import Postgres, Table -from test.utils import assert_matching_tables -import unittest import os +import unittest +from test.utils import assert_matching_tables + +from parsons import Postgres, Table # The name of the schema and will be temporarily created for the tests TEMP_SCHEMA = "parsons_test" diff --git a/test/test_databases/test_redshift.py b/test/test_databases/test_redshift.py index 08bc415c01..3473fcb502 100644 --- a/test/test_databases/test_redshift.py +++ b/test/test_databases/test_redshift.py @@ -1,11 +1,12 @@ -from parsons import Redshift, S3, Table -from test.utils import assert_matching_tables -import unittest import os import re -from test.utils import validate_list +import unittest +from test.utils import assert_matching_tables, validate_list + from testfixtures import LogCapture +from parsons import S3, Redshift, Table + # The name of the schema and will be temporarily created for the tests TEMP_SCHEMA = "parsons_test2" diff --git a/test/test_donorbox/test_donorbox.py b/test/test_donorbox/test_donorbox.py index 9e0479e866..801e7c90e6 100644 --- a/test/test_donorbox/test_donorbox.py +++ b/test/test_donorbox/test_donorbox.py @@ -1,11 +1,11 @@ import unittest +from test.test_donorbox import donorbox_test_data +from test.utils import mark_live_test + import requests_mock -from parsons import Table, Donorbox +from parsons import Donorbox, Table from parsons.donorbox.donorbox import URI -from test.utils import mark_live_test -from test.test_donorbox import donorbox_test_data - # NOTE: Donorbox does not provide free sandbox accounts to developers. To enable live tests, # get a paid account and remove the @skip decorators on the live tests below. diff --git a/test/test_facebook_ads.py b/test/test_facebook_ads.py index 942a3e0e38..bdf6ab503e 100644 --- a/test/test_facebook_ads.py +++ b/test/test_facebook_ads.py @@ -1,9 +1,8 @@ -import unittest import os +import unittest from parsons import FacebookAds, Table - users_table = Table( [ { diff --git a/test/test_formstack/test_formstack.py b/test/test_formstack/test_formstack.py index 101e5040f4..e724ba88ce 100644 --- a/test/test_formstack/test_formstack.py +++ b/test/test_formstack/test_formstack.py @@ -1,17 +1,18 @@ import unittest -import requests_mock -from parsons.formstack.formstack import Formstack, API_URI -from parsons import Table - from test.test_formstack.formstack_json import ( folder_json, + form_fields_json, form_json, + form_submissions_json, submission_id, submission_json, - form_submissions_json, - form_fields_json, ) +import requests_mock + +from parsons import Table +from parsons.formstack.formstack import API_URI, Formstack + VALID_RESPONSE_STATUS_CODE = 200 diff --git a/test/test_freshdesk/test_freshdesk.py b/test/test_freshdesk/test_freshdesk.py index b18021576f..7760f543c6 100644 --- a/test/test_freshdesk/test_freshdesk.py +++ b/test/test_freshdesk/test_freshdesk.py @@ -1,8 +1,10 @@ -from parsons import Freshdesk import unittest -import requests_mock from test.test_freshdesk import expected_json +import requests_mock + +from parsons import Freshdesk + DOMAIN = "myorg" API_KEY = "mykey" diff --git a/test/test_geocoder/test_census_geocoder.py b/test/test_geocoder/test_census_geocoder.py index bf7e57e349..b86323688b 100644 --- a/test/test_geocoder/test_census_geocoder.py +++ b/test/test_geocoder/test_census_geocoder.py @@ -1,10 +1,12 @@ -import unittest import os +import unittest +from test.utils import assert_matching_tables from unittest import mock -from parsons import Table, CensusGeocoder + import petl -from test_responses import geographies_resp, locations_resp, batch_resp, coord_resp -from test.utils import assert_matching_tables +from test_responses import batch_resp, coord_resp, geographies_resp, locations_resp + +from parsons import CensusGeocoder, Table @unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test") diff --git a/test/test_github/test_github.py b/test/test_github/test_github.py index 04d6ea4cc1..b06a329101 100644 --- a/test/test_github/test_github.py +++ b/test/test_github/test_github.py @@ -3,11 +3,11 @@ from unittest.mock import patch import requests_mock -from parsons import Table, GitHub + from github.GithubException import UnknownObjectException +from parsons import GitHub, Table from parsons.github.github import ParsonsGitHubError - _dir = os.path.dirname(__file__) diff --git a/test/test_gmail/test_gmail.py b/test/test_gmail/test_gmail.py index 35fc992774..de318da703 100644 --- a/test/test_gmail/test_gmail.py +++ b/test/test_gmail/test_gmail.py @@ -1,12 +1,13 @@ -from parsons import Gmail +import base64 +import email import json import os -import requests_mock -import unittest import shutil -import base64 -import email +import unittest +import requests_mock + +from parsons import Gmail _dir = os.path.dirname(__file__) diff --git a/test/test_google/test_google_admin.py b/test/test_google/test_google_admin.py index 4951892a67..10e2e53fa8 100644 --- a/test/test_google/test_google_admin.py +++ b/test/test_google/test_google_admin.py @@ -1,8 +1,9 @@ -from parsons.etl.table import Table -from parsons.google.google_admin import GoogleAdmin +import unittest from test.utils import assert_matching_tables from unittest.mock import MagicMock -import unittest + +from parsons.etl.table import Table +from parsons.google.google_admin import GoogleAdmin class MockGoogleAdmin(GoogleAdmin): diff --git a/test/test_google/test_google_cloud_storage.py b/test/test_google/test_google_cloud_storage.py index c6ad5fb2da..31c034e9c0 100644 --- a/test/test_google/test_google_cloud_storage.py +++ b/test/test_google/test_google_cloud_storage.py @@ -1,10 +1,10 @@ +import os import unittest -from parsons import GoogleCloudStorage, Table from test.utils import assert_matching_tables -from parsons.utilities import files -from google.cloud import storage -import os +from google.cloud import storage +from parsons import GoogleCloudStorage, Table +from parsons.utilities import files TEMP_BUCKET_NAME = "parsons_test" TEMP_FILE_NAME = "tmp_file_01.txt" diff --git a/test/test_google/test_google_sheets.py b/test/test_google/test_google_sheets.py index 755da68fcb..8f0fc4039c 100644 --- a/test/test_google/test_google_sheets.py +++ b/test/test_google/test_google_sheets.py @@ -1,10 +1,11 @@ -import unittest -import gspread import os import time +import unittest +from test.utils import assert_matching_tables + +import gspread from parsons import GoogleSheets, Table -from test.utils import assert_matching_tables @unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test") diff --git a/test/test_google/test_googlecivic.py b/test/test_google/test_googlecivic.py index ef6bece6c3..80ab055f2e 100644 --- a/test/test_google/test_googlecivic.py +++ b/test/test_google/test_googlecivic.py @@ -1,14 +1,11 @@ import unittest -import requests_mock -from parsons import Table, GoogleCivic -from googlecivic_responses import ( - elections_resp, - voterinfo_resp, - polling_data, - representatives_resp, -) from test.utils import assert_matching_tables +import requests_mock +from googlecivic_responses import elections_resp, polling_data, representatives_resp, voterinfo_resp + +from parsons import GoogleCivic, Table + class TestGoogleCivic(unittest.TestCase): def setUp(self): diff --git a/test/test_hustle/test_hustle.py b/test/test_hustle/test_hustle.py index e561977188..ba4337fadf 100644 --- a/test/test_hustle/test_hustle.py +++ b/test/test_hustle/test_hustle.py @@ -1,8 +1,10 @@ import unittest -import requests_mock -from test.utils import assert_matching_tables from test.test_hustle import expected_json -from parsons import Table, Hustle +from test.utils import assert_matching_tables + +import requests_mock + +from parsons import Hustle, Table from parsons.hustle.hustle import HUSTLE_URI CLIENT_ID = "FAKE_ID" diff --git a/test/test_mailchimp/test_mailchimp.py b/test/test_mailchimp/test_mailchimp.py index f8b274f552..e0d4bec421 100644 --- a/test/test_mailchimp/test_mailchimp.py +++ b/test/test_mailchimp/test_mailchimp.py @@ -1,8 +1,10 @@ -from parsons import Mailchimp import unittest -import requests_mock from test.test_mailchimp import expected_json +import requests_mock + +from parsons import Mailchimp + API_KEY = "mykey-us00" diff --git a/test/test_mobilecommons/test_mobilecommons.py b/test/test_mobilecommons/test_mobilecommons.py index 8132a7a4df..6c57d60ac2 100644 --- a/test/test_mobilecommons/test_mobilecommons.py +++ b/test/test_mobilecommons/test_mobilecommons.py @@ -1,13 +1,14 @@ import unittest + import requests_mock -from parsons.mobilecommons import MobileCommons -from parsons.etl import Table from mobilecommons_responses import ( - get_profiles_response, get_broadcasts_response, + get_profiles_response, post_profile_response, ) +from parsons.etl import Table +from parsons.mobilecommons import MobileCommons MOBILECOMMONS_USERNAME = "MOBILECOMMONS_USERNAME" MOBILECOMMONS_PASSWORD = "MOBILECOMMONS_PASSWORD" diff --git a/test/test_mobilize/test_mobilize_america.py b/test/test_mobilize/test_mobilize_america.py index 167485ca8b..f9a69b4aa0 100644 --- a/test/test_mobilize/test_mobilize_america.py +++ b/test/test_mobilize/test_mobilize_america.py @@ -1,8 +1,10 @@ +import test.test_mobilize.test_mobilize_json as test_json import unittest +from test.utils import validate_list + import requests_mock + from parsons import MobilizeAmerica -from test.utils import validate_list -import test.test_mobilize.test_mobilize_json as test_json class TestMobilizeAmerica(unittest.TestCase): diff --git a/test/test_newmode/test_newmode.py b/test/test_newmode/test_newmode.py index 294e8ca478..91356b23be 100644 --- a/test/test_newmode/test_newmode.py +++ b/test/test_newmode/test_newmode.py @@ -1,6 +1,7 @@ import os import unittest import unittest.mock as mock + from parsons import Newmode diff --git a/test/test_p2a.py b/test/test_p2a.py index 8e60f0a360..1a19c4a1bd 100644 --- a/test/test_p2a.py +++ b/test/test_p2a.py @@ -1,10 +1,11 @@ +import copy +import os import unittest -import requests_mock from test.utils import validate_list -from parsons import Phone2Action -import os -import copy +import requests_mock + +from parsons import Phone2Action adv_json = { "data": [ diff --git a/test/test_pdi/conftest.py b/test/test_pdi/conftest.py index 5eb510e022..e125d3634a 100644 --- a/test/test_pdi/conftest.py +++ b/test/test_pdi/conftest.py @@ -1,8 +1,9 @@ -from parsons.pdi.pdi import PDI - import os + import pytest +from parsons.pdi.pdi import PDI + @pytest.fixture def live_pdi(): diff --git a/test/test_pdi/test_events.py b/test/test_pdi/test_events.py index 36791e8b98..380c1f569c 100644 --- a/test/test_pdi/test_events.py +++ b/test/test_pdi/test_events.py @@ -1,4 +1,5 @@ from test.utils import mark_live_test + from parsons import Table ##### diff --git a/test/test_pdi/test_flag_ids.py b/test/test_pdi/test_flag_ids.py index e69ce5e9c8..acff7868e3 100644 --- a/test/test_pdi/test_flag_ids.py +++ b/test/test_pdi/test_flag_ids.py @@ -1,12 +1,11 @@ -from test.utils import mark_live_test - -from parsons import Table - from contextlib import contextmanager -from requests.exceptions import HTTPError +from test.utils import mark_live_test # import json import pytest +from requests.exceptions import HTTPError + +from parsons import Table # # Fixtures and constants diff --git a/test/test_pdi/test_pdi.py b/test/test_pdi/test_pdi.py index 52cc7bb383..ff9dc9ed31 100644 --- a/test/test_pdi/test_pdi.py +++ b/test/test_pdi/test_pdi.py @@ -1,8 +1,9 @@ +import os from test.utils import mark_live_test -from parsons import PDI import pytest -import os + +from parsons import PDI # diff --git a/test/test_quickbase/test_quickbase.py b/test/test_quickbase/test_quickbase.py index 3efbb41ea3..3f05f950c7 100644 --- a/test/test_quickbase/test_quickbase.py +++ b/test/test_quickbase/test_quickbase.py @@ -1,7 +1,9 @@ import unittest +from test.test_quickbase import test_data + import requests_mock + from parsons import Quickbase -from test.test_quickbase import test_data class TestQuickbase(unittest.TestCase): diff --git a/test/test_redash.py b/test/test_redash.py index 35556ecced..1f65a952ef 100644 --- a/test/test_redash.py +++ b/test/test_redash.py @@ -1,10 +1,11 @@ import os import unittest -import requests_mock from test.utils import assert_matching_tables -from parsons import Table, Redash -from parsons.redash.redash import RedashTimeout +import requests_mock + +from parsons import Redash, Table +from parsons.redash.redash import RedashTimeout BASE_URL = "https://redash.example.com" API_KEY = "abc123" diff --git a/test/test_rockthevote/test_rtv.py b/test/test_rockthevote/test_rtv.py index 7c229d56fd..5b178e8f67 100644 --- a/test/test_rockthevote/test_rtv.py +++ b/test/test_rockthevote/test_rtv.py @@ -1,8 +1,8 @@ +import json import os import unittest import requests_mock -import json from parsons import RockTheVote diff --git a/test/test_s3.py b/test/test_s3.py index 6904f72820..51052c259f 100644 --- a/test/test_s3.py +++ b/test/test_s3.py @@ -1,11 +1,13 @@ -import unittest import os +import time +import unittest +import urllib from datetime import datetime +from test.utils import assert_matching_tables + import pytz + from parsons import S3, Table -import urllib -import time -from test.utils import assert_matching_tables # Requires a s3 credentials stored in aws config or env variable # to run properly. diff --git a/test/test_salesforce/test_salesforce.py b/test/test_salesforce/test_salesforce.py index 1ee565dbc9..c93be5c8ff 100644 --- a/test/test_salesforce/test_salesforce.py +++ b/test/test_salesforce/test_salesforce.py @@ -1,6 +1,7 @@ import os import unittest import unittest.mock as mock + from parsons import Salesforce, Table diff --git a/test/test_scytl/test_scytl.py b/test/test_scytl/test_scytl.py index 5544cf78d2..ab1aa55dcf 100644 --- a/test/test_scytl/test_scytl.py +++ b/test/test_scytl/test_scytl.py @@ -1,7 +1,9 @@ -import unittest +import csv import os +import unittest + import requests_mock -import csv + from parsons.scytl import Scytl, scytl TEST_STATE = "GA" diff --git a/test/test_sendmail.py b/test/test_sendmail.py index 47a56d6b8a..d1ee71a406 100644 --- a/test/test_sendmail.py +++ b/test/test_sendmail.py @@ -1,11 +1,12 @@ import io -import pytest -from email.mime.text import MIMEText -from email.mime.multipart import MIMEMultipart -from email.mime.image import MIMEImage -from email.mime.audio import MIMEAudio from email.mime.application import MIMEApplication +from email.mime.audio import MIMEAudio from email.mime.base import MIMEBase +from email.mime.image import MIMEImage +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText + +import pytest from parsons.notifications.sendmail import EmptyListError, SendMail diff --git a/test/test_sftp.py b/test/test_sftp.py index 7329a0fa61..7804e84926 100644 --- a/test/test_sftp.py +++ b/test/test_sftp.py @@ -1,17 +1,15 @@ -import pytest import os -import paramiko from contextlib import contextmanager from copy import deepcopy -from unittest.mock import MagicMock, patch, call -from parsons import Table, SFTP +from test.fixtures import simple_compressed_csv_path, simple_csv_path, simple_table # noqa: F401 +from test.utils import assert_matching_tables, mark_live_test +from unittest.mock import MagicMock, call, patch + +import paramiko +import pytest + +from parsons import SFTP, Table from parsons.utilities import files as file_util -from test.utils import mark_live_test, assert_matching_tables -from test.fixtures import ( # noqa: F401 - simple_table, - simple_csv_path, - simple_compressed_csv_path, -) # # Fixtures and constants diff --git a/test/test_sftp_ssh.py b/test/test_sftp_ssh.py index 60e29accbf..11612ac051 100644 --- a/test/test_sftp_ssh.py +++ b/test/test_sftp_ssh.py @@ -1,14 +1,11 @@ -import pytest import os -from parsons import Table, SFTP -from parsons.utilities import files -from test.utils import mark_live_test, assert_matching_tables -from test.fixtures import ( # noqa: F401 - simple_table, - simple_csv_path, - simple_compressed_csv_path, -) +from test.fixtures import simple_compressed_csv_path, simple_csv_path, simple_table # noqa: F401 +from test.utils import assert_matching_tables, mark_live_test +import pytest + +from parsons import SFTP, Table +from parsons.utilities import files # # Fixtures and constants diff --git a/test/test_shopify.py b/test/test_shopify.py index 780e30ee8f..ab7ae74311 100644 --- a/test/test_shopify.py +++ b/test/test_shopify.py @@ -1,7 +1,9 @@ -from parsons import Table, Shopify +import unittest from test.utils import assert_matching_tables + import requests_mock -import unittest + +from parsons import Shopify, Table SUBDOMAIN = "myorg" PASSWORD = "abc123" diff --git a/test/test_sisense/test_sisense.py b/test/test_sisense/test_sisense.py index c8ec43990c..b887b0011c 100644 --- a/test/test_sisense/test_sisense.py +++ b/test/test_sisense/test_sisense.py @@ -1,15 +1,16 @@ import os import unittest -from unittest import mock -import requests_mock -from parsons import Sisense - from test.test_sisense.test_data import ( ENV_PARAMETERS, - TEST_PUBLISH_SHARED_DASHBOARD, - TEST_LIST_SHARED_DASHBOARDS, TEST_DELETE_SHARED_DASHBOARD, + TEST_LIST_SHARED_DASHBOARDS, + TEST_PUBLISH_SHARED_DASHBOARD, ) +from unittest import mock + +import requests_mock + +from parsons import Sisense class TestSisense(unittest.TestCase): diff --git a/test/test_slack/test_slack.py b/test/test_slack/test_slack.py index 7ed3f78b4c..1d06736911 100644 --- a/test/test_slack/test_slack.py +++ b/test/test_slack/test_slack.py @@ -1,12 +1,11 @@ -from parsons import Table, Slack - -from slackclient.exceptions import SlackClientError - +import json import os -import requests_mock import unittest -import json +import requests_mock +from slackclient.exceptions import SlackClientError + +from parsons import Slack, Table _dir = os.path.dirname(__file__) responses_dir = f"{_dir}/responses" diff --git a/test/test_smtp.py b/test/test_smtp.py index 1da36788b6..f211b941c1 100644 --- a/test/test_smtp.py +++ b/test/test_smtp.py @@ -1,9 +1,10 @@ -from parsons import SMTP import base64 import io import re import unittest +from parsons import SMTP + class FakeConnection(object): def __init__(self, result_obj): diff --git a/test/test_targetsmart/test_targetsmart_api.py b/test/test_targetsmart/test_targetsmart_api.py index 7c89cb4a45..3aaf554d94 100644 --- a/test/test_targetsmart/test_targetsmart_api.py +++ b/test/test_targetsmart/test_targetsmart_api.py @@ -1,17 +1,19 @@ import unittest -import requests_mock -from parsons import TargetSmartAPI, Table -from test.utils import validate_list from test.responses.ts_responses import ( address_response, - district_point, district_expected, + district_point, district_zip, - zip_expected, - phone_response, phone_expected, + phone_response, radius_response, + zip_expected, ) +from test.utils import validate_list + +import requests_mock + +from parsons import Table, TargetSmartAPI output_list = [ { diff --git a/test/test_targetsmart/test_targetsmart_automation.py b/test/test_targetsmart/test_targetsmart_automation.py index a13969677e..eadc081ae6 100644 --- a/test/test_targetsmart/test_targetsmart_automation.py +++ b/test/test_targetsmart/test_targetsmart_automation.py @@ -1,7 +1,8 @@ -from parsons import TargetSmartAutomation, SFTP +import os import unittest from test.utils import mark_live_test -import os + +from parsons import SFTP, TargetSmartAutomation class TestTargetSmartAutomation(unittest.TestCase): diff --git a/test/test_targetsmart/test_targetsmart_smartmatch.py b/test/test_targetsmart/test_targetsmart_smartmatch.py index 5bff6deb84..07fa95800a 100644 --- a/test/test_targetsmart/test_targetsmart_smartmatch.py +++ b/test/test_targetsmart/test_targetsmart_smartmatch.py @@ -1,6 +1,6 @@ import csv -import io import gzip +import io import sys import petl diff --git a/test/test_turbovote/test_turbovote.py b/test/test_turbovote/test_turbovote.py index 1351ed1fcb..bc46461422 100644 --- a/test/test_turbovote/test_turbovote.py +++ b/test/test_turbovote/test_turbovote.py @@ -1,8 +1,10 @@ -import unittest import os +import unittest +from test.utils import validate_list + import requests_mock + from parsons import TurboVote -from test.utils import validate_list _dir = os.path.dirname(__file__) diff --git a/test/test_twilio/test_twilio.py b/test/test_twilio/test_twilio.py index 652582c079..3b105a3b27 100644 --- a/test/test_twilio/test_twilio.py +++ b/test/test_twilio/test_twilio.py @@ -1,6 +1,7 @@ import os import unittest import unittest.mock as mock + from parsons import Twilio diff --git a/test/test_utilities.py b/test/test_utilities.py index 539d08bd10..3967b310f1 100644 --- a/test/test_utilities.py +++ b/test/test_utilities.py @@ -1,16 +1,15 @@ -import unittest +import datetime import os -import pytest import shutil -import datetime +import unittest +from test.conftest import xfail_value_error from unittest import mock + +import pytest + from parsons import Table +from parsons.utilities import check_env, files, json_format, sql_helpers from parsons.utilities.datetime import date_to_timestamp, parse_date -from parsons.utilities import files -from parsons.utilities import check_env -from parsons.utilities import json_format -from parsons.utilities import sql_helpers -from test.conftest import xfail_value_error @pytest.mark.parametrize( diff --git a/test/test_utilities/test_format_phone_number.py b/test/test_utilities/test_format_phone_number.py index aeafb8ad7c..1021cc9d2c 100644 --- a/test/test_utilities/test_format_phone_number.py +++ b/test/test_utilities/test_format_phone_number.py @@ -1,4 +1,5 @@ import unittest + from parsons.utilities.format_phone_number import format_phone_number diff --git a/test/test_utilities/test_ssh_utilities.py b/test/test_utilities/test_ssh_utilities.py index 5fe5a6a1d4..d07fbb1e4e 100644 --- a/test/test_utilities/test_ssh_utilities.py +++ b/test/test_utilities/test_ssh_utilities.py @@ -1,5 +1,6 @@ import unittest -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch + from parsons.utilities.ssh_utilities import query_through_ssh diff --git a/test/test_van/test_activist_codes.py b/test/test_van/test_activist_codes.py index e977d5a016..f4602509e1 100644 --- a/test/test_van/test_activist_codes.py +++ b/test/test_van/test_activist_codes.py @@ -1,8 +1,10 @@ -import unittest import os +import unittest +from test.utils import validate_list + import requests_mock + from parsons import VAN -from test.utils import validate_list os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_bulkimport.py b/test/test_van/test_bulkimport.py index d36c8da00c..f2f7408c8e 100644 --- a/test/test_van/test_bulkimport.py +++ b/test/test_van/test_bulkimport.py @@ -1,9 +1,11 @@ -import unittest import os -import requests_mock +import unittest import unittest.mock as mock -from parsons import VAN, Table from test.utils import assert_matching_tables + +import requests_mock + +from parsons import VAN, Table from parsons.utilities import cloud_storage os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_changed_entities.py b/test/test_van/test_changed_entities.py index bcbdf3fb9b..4d30263cab 100644 --- a/test/test_van/test_changed_entities.py +++ b/test/test_van/test_changed_entities.py @@ -1,10 +1,12 @@ -import unittest import os -import requests_mock +import unittest import unittest.mock as mock -from parsons import VAN, Table from test.utils import assert_matching_tables +import requests_mock + +from parsons import VAN, Table + class TestNGPVAN(unittest.TestCase): def setUp(self): diff --git a/test/test_van/test_codes.py b/test/test_van/test_codes.py index 1f416847e0..f95e071816 100644 --- a/test/test_van/test_codes.py +++ b/test/test_van/test_codes.py @@ -1,10 +1,12 @@ -import unittest import os -import requests_mock -from parsons import VAN +import unittest from test.utils import assert_matching_tables + +import requests_mock from requests.exceptions import HTTPError +from parsons import VAN + os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_contact_notes.py b/test/test_van/test_contact_notes.py index 010aa6676b..cb5aaf1b1c 100644 --- a/test/test_van/test_contact_notes.py +++ b/test/test_van/test_contact_notes.py @@ -1,9 +1,11 @@ -from parsons import VAN +import os +import unittest from test.test_van.responses_people import get_person_response from test.utils import assert_matching_tables + import requests_mock -import os -import unittest + +from parsons import VAN os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_custom_fields.py b/test/test_van/test_custom_fields.py index c986caa03d..05d829f21d 100644 --- a/test/test_van/test_custom_fields.py +++ b/test/test_van/test_custom_fields.py @@ -1,9 +1,10 @@ -import unittest import os -import requests_mock -from parsons import VAN +import unittest from test.utils import assert_matching_tables +import requests_mock + +from parsons import VAN custom_field = [ { diff --git a/test/test_van/test_email.py b/test/test_van/test_email.py index 64fc4cef3e..a025e16208 100644 --- a/test/test_van/test_email.py +++ b/test/test_van/test_email.py @@ -1,7 +1,9 @@ -import unittest import os -import requests_mock +import unittest from copy import deepcopy + +import requests_mock + from parsons import VAN, Table diff --git a/test/test_van/test_events.py b/test/test_van/test_events.py index 60cef0a25b..b8bfbf1ac0 100644 --- a/test/test_van/test_events.py +++ b/test/test_van/test_events.py @@ -1,9 +1,10 @@ -import unittest import os -import requests_mock -from parsons import VAN +import unittest from test.utils import validate_list +import requests_mock + +from parsons import VAN os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_locations.py b/test/test_van/test_locations.py index 7fa6234c33..7fa95d8080 100644 --- a/test/test_van/test_locations.py +++ b/test/test_van/test_locations.py @@ -1,10 +1,11 @@ -import unittest import os -import requests_mock -from parsons import VAN +import unittest from test.utils import validate_list + +import requests_mock from requests.exceptions import HTTPError +from parsons import VAN os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_ngpvan.py b/test/test_van/test_ngpvan.py index 73ee156cc9..5bc82a8d0f 100644 --- a/test/test_van/test_ngpvan.py +++ b/test/test_van/test_ngpvan.py @@ -1,10 +1,12 @@ import os import unittest +from test.utils import assert_matching_tables, validate_list + import requests_mock -from parsons import VAN, Table -from test.utils import validate_list, assert_matching_tables from requests.exceptions import HTTPError +from parsons import VAN, Table + class TestNGPVAN(unittest.TestCase): def setUp(self): diff --git a/test/test_van/test_people.py b/test/test_van/test_people.py index 82dfbdc002..1d90799ece 100644 --- a/test/test_van/test_people.py +++ b/test/test_van/test_people.py @@ -1,15 +1,17 @@ -import unittest import os -import requests_mock -from parsons import VAN -from requests.exceptions import HTTPError +import unittest from test.test_van.responses_people import ( + delete_person_response, find_people_response, get_person_response, merge_contacts_response, - delete_person_response, ) +import requests_mock +from requests.exceptions import HTTPError + +from parsons import VAN + os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_printed_lists.py b/test/test_van/test_printed_lists.py index b9c1bcf823..271a44358b 100644 --- a/test/test_van/test_printed_lists.py +++ b/test/test_van/test_printed_lists.py @@ -1,8 +1,10 @@ -import unittest import os +import unittest +from test.test_van.responses_printed_lists import list_json, single_list_json + import requests_mock + from parsons import VAN -from test.test_van.responses_printed_lists import list_json, single_list_json class TestSavedLists(unittest.TestCase): diff --git a/test/test_van/test_saved_lists.py b/test/test_van/test_saved_lists.py index 471d43c687..7ac85c792d 100644 --- a/test/test_van/test_saved_lists.py +++ b/test/test_van/test_saved_lists.py @@ -1,9 +1,11 @@ -import unittest import os -import requests_mock +import unittest import unittest.mock as mock -from parsons import VAN, Table from test.utils import validate_list + +import requests_mock + +from parsons import VAN, Table from parsons.utilities import cloud_storage diff --git a/test/test_van/test_scores.py b/test/test_van/test_scores.py index 75d88b7491..b7d648be8a 100644 --- a/test/test_van/test_scores.py +++ b/test/test_van/test_scores.py @@ -1,11 +1,12 @@ -import unittest import os -import requests_mock +import unittest import unittest.mock as mock -from parsons import VAN, Table from test.utils import validate_list -from parsons.utilities import cloud_storage +import requests_mock + +from parsons import VAN, Table +from parsons.utilities import cloud_storage os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_van/test_signups.py b/test/test_van/test_signups.py index d7d5991b2e..5825cb0cb7 100644 --- a/test/test_van/test_signups.py +++ b/test/test_van/test_signups.py @@ -1,8 +1,10 @@ -import unittest import os +import unittest +from test.utils import validate_list + import requests_mock + from parsons import VAN -from test.utils import validate_list signup_status = [ {"statusId": 5, "name": "Cancelled"}, diff --git a/test/test_van/test_targets.py b/test/test_van/test_targets.py index 2e688ee385..10401c06d5 100644 --- a/test/test_van/test_targets.py +++ b/test/test_van/test_targets.py @@ -1,9 +1,11 @@ -import unittest.mock import os +import unittest.mock +from test.utils import assert_matching_tables, validate_list + +import petl import requests_mock + from parsons import VAN, Table -import petl -from test.utils import validate_list, assert_matching_tables os.environ["VAN_API_KEY"] = "SOME_KEY" diff --git a/test/test_zoom.py b/test/test_zoom.py index 2569e24e8c..9b00572d60 100644 --- a/test/test_zoom.py +++ b/test/test_zoom.py @@ -2,6 +2,7 @@ from test.utils import assert_matching_tables import requests_mock + from parsons import Table, Zoom ACCOUNT_ID = "fakeAccountID" diff --git a/test/utils.py b/test/utils.py index f5fc737232..971c0763a4 100644 --- a/test/utils.py +++ b/test/utils.py @@ -1,7 +1,9 @@ -from parsons.etl.table import Table import os + import pytest +from parsons.etl.table import Table + """ Use this as a marker before any tests that hit live services. That way they'll only run if you set the "LIVE_TEST" env var. diff --git a/useful_resources/sample_code/apply_activist_code.py b/useful_resources/sample_code/apply_activist_code.py index b11a78c536..b267c3c6d7 100644 --- a/useful_resources/sample_code/apply_activist_code.py +++ b/useful_resources/sample_code/apply_activist_code.py @@ -26,10 +26,11 @@ # ### CODE -from parsons import Table, Redshift, VAN # noqa E402 -from parsons import logger # noqa E402 import os # noqa E402 +from parsons import logger # noqa E402 +from parsons import VAN, Redshift, Table # noqa E402 + # Setup for name, value in config_vars.items(): # sets variables if provided in this script diff --git a/useful_resources/sample_code/civis_job_status_slack_alert.py b/useful_resources/sample_code/civis_job_status_slack_alert.py index db7ce618ea..cccd9eb024 100644 --- a/useful_resources/sample_code/civis_job_status_slack_alert.py +++ b/useful_resources/sample_code/civis_job_status_slack_alert.py @@ -1,9 +1,10 @@ # This script checks the status of all jobs and workflows in a given Civis Project # and posts them to a Slack channel. -import civis import datetime import logging + +import civis from parsons import Slack, Table # Environment variables diff --git a/useful_resources/sample_code/mysql_to_googlesheets.py b/useful_resources/sample_code/mysql_to_googlesheets.py index d13df38397..4b70f46480 100644 --- a/useful_resources/sample_code/mysql_to_googlesheets.py +++ b/useful_resources/sample_code/mysql_to_googlesheets.py @@ -2,9 +2,11 @@ import logging import time -from parsons import GoogleSheets, MySQL + from gspread.exceptions import APIError +from parsons import GoogleSheets, MySQL + logger = logging.getLogger(__name__) _handler = logging.StreamHandler() _formatter = logging.Formatter("%(levelname)s %(message)s") diff --git a/useful_resources/sample_code/ngpvan_sample_list.py b/useful_resources/sample_code/ngpvan_sample_list.py index 01973a8244..02c6146af6 100644 --- a/useful_resources/sample_code/ngpvan_sample_list.py +++ b/useful_resources/sample_code/ngpvan_sample_list.py @@ -27,6 +27,7 @@ import os # noqa: E402 import random # noqa: E402 + from parsons import VAN # noqa: E402 from parsons import logger # noqa: E402 diff --git a/useful_resources/sample_code/ngpvan_sample_printed_list.py b/useful_resources/sample_code/ngpvan_sample_printed_list.py index ff52b799b8..1b6a608a7e 100644 --- a/useful_resources/sample_code/ngpvan_sample_printed_list.py +++ b/useful_resources/sample_code/ngpvan_sample_printed_list.py @@ -15,10 +15,10 @@ --gsheet_uri="{URI for gsheet where NGP VAN data will be stored}" """ -from fpdf import FPDF -from parsons import VAN, GoogleSheets, Table import click +from fpdf import FPDF +from parsons import VAN, GoogleSheets, Table # ~~~~~~~~~~~~~~ Get Printed and Saved List Info From VAN ~~~~~~~~~~~~~~~~# diff --git a/useful_resources/sample_code/opt_outs_everyaction.py b/useful_resources/sample_code/opt_outs_everyaction.py index 8d377d786c..237810cbc4 100644 --- a/useful_resources/sample_code/opt_outs_everyaction.py +++ b/useful_resources/sample_code/opt_outs_everyaction.py @@ -1,11 +1,12 @@ +import json import os -import requests import time -import json -from parsons import Redshift, Table, VAN -from parsons import logger from datetime import datetime +import requests + +from parsons import VAN, Redshift, Table, logger + # Committee Information and Credentials # This script can be run against multiple EveryAction committees. diff --git a/useful_resources/sample_code/s3_to_redshift.py b/useful_resources/sample_code/s3_to_redshift.py index 1917966395..3617022b4e 100644 --- a/useful_resources/sample_code/s3_to_redshift.py +++ b/useful_resources/sample_code/s3_to_redshift.py @@ -28,7 +28,8 @@ # ### CODE import os # noqa E402 -from parsons import Redshift, S3, utilities, logger # noqa E402 + +from parsons import S3, Redshift, logger, utilities # noqa E402 # Setup diff --git a/useful_resources/sample_code/s3_to_s3.py b/useful_resources/sample_code/s3_to_s3.py index 60318bf9a3..20aa3d3a30 100644 --- a/useful_resources/sample_code/s3_to_s3.py +++ b/useful_resources/sample_code/s3_to_s3.py @@ -25,7 +25,8 @@ # ### CODE import os # noqa: E402 -from parsons import S3, utilities, logger # noqa: E402 + +from parsons import S3, logger, utilities # noqa: E402 # Setup diff --git a/useful_resources/sample_code/update_user_in_actionkit.py b/useful_resources/sample_code/update_user_in_actionkit.py index 2ea2b3d068..7a98a4a300 100644 --- a/useful_resources/sample_code/update_user_in_actionkit.py +++ b/useful_resources/sample_code/update_user_in_actionkit.py @@ -25,9 +25,10 @@ # ### CODE -import os # noqa: E402 import datetime # noqa: E402 -from parsons import Redshift, Table, ActionKit, logger # noqa: E402 +import os # noqa: E402 + +from parsons import ActionKit, Redshift, Table, logger # noqa: E402 # Setup diff --git a/useful_resources/sample_code/zoom_to_van.py b/useful_resources/sample_code/zoom_to_van.py index 2a1a78d217..76aab7094c 100644 --- a/useful_resources/sample_code/zoom_to_van.py +++ b/useful_resources/sample_code/zoom_to_van.py @@ -26,6 +26,7 @@ # Setup import os # noqa: E402 + from parsons import VAN, Zoom # noqa: E402 # if variables specified above, sets them as environmental variables