Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_|

# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_
ignored-argument-names=_.*|^ignored_|^unused_|^kwargs|^args|^mock_.+

# Tells whether we should check for unused import in __init__ files.
init-import=no
Expand Down
34 changes: 0 additions & 34 deletions scripts/ci/pylint_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -431,23 +431,18 @@
./tests/contrib/hooks/test_aws_lambda_hook.py
./tests/contrib/hooks/test_azure_container_instance_hook.py
./tests/contrib/hooks/test_azure_cosmos_hook.py
./tests/contrib/hooks/test_azure_data_lake_hook.py
./tests/contrib/hooks/test_bigquery_hook.py
./tests/contrib/hooks/test_cassandra_hook.py
./tests/contrib/hooks/test_cloudant_hook.py
./tests/contrib/hooks/test_databricks_hook.py
./tests/contrib/hooks/test_datadog_hook.py
./tests/contrib/hooks/test_datastore_hook.py
./tests/contrib/hooks/test_discord_webhook_hook.py
./tests/contrib/hooks/test_ftp_hook.py
./tests/contrib/hooks/test_grpc_hook.py
./tests/contrib/hooks/test_imap_hook.py
./tests/contrib/hooks/test_jira_hook.py
./tests/contrib/hooks/test_mongo_hook.py
./tests/contrib/hooks/test_openfaas_hook.py
./tests/contrib/hooks/test_opsgenie_alert_hook.py
./tests/contrib/hooks/test_redshift_hook.py
./tests/contrib/hooks/test_sagemaker_hook.py
./tests/contrib/hooks/test_salesforce_hook.py
./tests/contrib/hooks/test_segment_hook.py
./tests/contrib/hooks/test_sftp_hook.py
Expand All @@ -457,59 +452,36 @@
./tests/contrib/hooks/test_spark_submit_hook.py
./tests/contrib/hooks/test_sqoop_hook.py
./tests/contrib/hooks/test_ssh_hook.py
./tests/contrib/hooks/test_winrm_hook.py
./tests/contrib/hooks/test_zendesk_hook.py
./tests/contrib/operators/test_adls_to_gcs_operator.py
./tests/contrib/operators/test_aws_athena_operator.py
./tests/contrib/operators/test_aws_sqs_publish_operator.py
./tests/contrib/operators/test_azure_container_instances_operator.py
./tests/contrib/operators/test_azure_cosmos_insertdocument_operator.py
./tests/contrib/operators/test_bigquery_operator.py
./tests/contrib/operators/test_cassandra_to_gcs_operator.py
./tests/contrib/operators/test_druid_operator.py
./tests/contrib/operators/test_ecs_operator.py
./tests/contrib/operators/test_emr_add_steps_operator.py
./tests/contrib/operators/test_emr_create_job_flow_operator.py
./tests/contrib/operators/test_gcs_to_s3_operator.py
./tests/contrib/operators/test_grpc_operator.py
./tests/contrib/operators/test_hive_to_dynamodb_operator.py
./tests/contrib/operators/test_mlengine_operator.py
./tests/contrib/operators/test_mssql_to_gcs_operator.py
./tests/contrib/operators/test_mysql_to_gcs_operator.py
./tests/contrib/operators/test_oracle_to_azure_data_lake_transfer.py
./tests/contrib/operators/test_postgres_to_gcs_operator.py
./tests/contrib/operators/test_qubole_check_operator.py
./tests/contrib/operators/test_redis_publish_operator.py
./tests/contrib/operators/test_s3_copy_object_operator.py
./tests/contrib/operators/test_s3_delete_objects_operator.py
./tests/contrib/operators/test_s3_to_gcs_operator.py
./tests/contrib/operators/test_s3_to_sftp_operator.py
./tests/contrib/operators/test_sagemaker_endpoint_config_operator.py
./tests/contrib/operators/test_sagemaker_endpoint_operator.py
./tests/contrib/operators/test_sagemaker_model_operator.py
./tests/contrib/operators/test_sagemaker_training_operator.py
./tests/contrib/operators/test_sagemaker_transform_operator.py
./tests/contrib/operators/test_sagemaker_tuning_operator.py
./tests/contrib/operators/test_segment_track_event_operator.py
./tests/contrib/operators/test_sftp_operator.py
./tests/contrib/operators/test_snowflake_operator.py
./tests/contrib/operators/test_spark_submit_operator.py
./tests/contrib/operators/test_ssh_operator.py
./tests/contrib/operators/test_vertica_to_mysql.py
./tests/contrib/sensors/test_athena_sensor.py
./tests/contrib/sensors/test_aws_redshift_cluster_sensor.py
./tests/contrib/sensors/test_bash_sensor.py
./tests/contrib/sensors/test_celery_queue_sensor.py
./tests/contrib/sensors/test_emr_step_sensor.py
./tests/contrib/sensors/test_file_sensor.py
./tests/contrib/sensors/test_ftp_sensor.py
./tests/contrib/sensors/test_jira_sensor_test.py
./tests/contrib/sensors/test_python_sensor.py
./tests/contrib/sensors/test_redis_pub_sub_sensor.py
./tests/contrib/sensors/test_sagemaker_endpoint_sensor.py
./tests/contrib/sensors/test_sagemaker_training_sensor.py
./tests/contrib/sensors/test_sagemaker_transform_sensor.py
./tests/contrib/sensors/test_sagemaker_tuning_sensor.py
./tests/contrib/sensors/test_sqs_sensor.py
./tests/contrib/sensors/test_weekday_sensor.py
./tests/contrib/utils/logging_command_executor.py
Expand All @@ -525,14 +497,11 @@
./tests/dags/test_impersonation_custom.py
./tests/dags/test_no_impersonation.py
./tests/dags/test_retry_handling_job.py
./tests/dags/test_task_view_type_check.py
./tests/executors/test_base_executor.py
./tests/executors/test_celery_executor.py
./tests/executors/test_dask_executor.py
./tests/executors/test_executor.py
./tests/executors/test_kubernetes_executor.py
./tests/executors/test_local_executor.py
./tests/executors/test_sequential_executor.py
./tests/hooks/test_docker_hook.py
./tests/hooks/test_druid_hook.py
./tests/hooks/test_hive_hook.py
Expand Down Expand Up @@ -566,9 +535,7 @@
./tests/operators/test_check_operator.py
./tests/operators/test_docker_operator.py
./tests/operators/test_hive_operator.py
./tests/operators/test_hive_stats_operator.py
./tests/operators/test_hive_to_druid.py
./tests/operators/test_hive_to_mysql.py
./tests/operators/test_mssql_to_hive.py
./tests/operators/test_operators.py
./tests/operators/test_papermill_operator.py
Expand Down Expand Up @@ -603,7 +570,6 @@
./tests/ti_deps/deps/test_ready_to_reschedule_dep.py
./tests/ti_deps/deps/test_runnable_exec_date_dep.py
./tests/utils/log/elasticmock/fake_elasticsearch.py
./tests/utils/log/elasticmock/__init__.py
./tests/utils/log/test_es_task_handler.py
./tests/utils/log/test_file_processor_handler.py
./tests/utils/log/test_s3_task_handler.py
Expand Down
66 changes: 33 additions & 33 deletions tests/contrib/hooks/test_azure_cosmos_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,61 +56,61 @@ def setUp(self):
)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_create_database(self, cosmos_mock):
def test_create_database(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.cosmos.create_database(self.test_database_name)
expected_calls = [mock.call().CreateDatabase({'id': self.test_database_name})]
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_create_database_exception(self, cosmos_mock):
def test_create_database_exception(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.assertRaises(AirflowException, self.cosmos.create_database, None)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_create_container_exception(self, cosmos_mock):
def test_create_container_exception(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.assertRaises(AirflowException, self.cosmos.create_collection, None)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_create_container(self, cosmos_mock):
def test_create_container(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.cosmos.create_collection(self.test_collection_name, self.test_database_name)
expected_calls = [mock.call().CreateContainer(
'dbs/test_database_name',
{'id': self.test_collection_name})]
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_create_container_default(self, cosmos_mock):
def test_create_container_default(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.cosmos.create_collection(self.test_collection_name)
expected_calls = [mock.call().CreateContainer(
'dbs/test_database_default',
{'id': self.test_collection_name})]
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_upsert_document_default(self, cosmos_mock):
def test_upsert_document_default(self, mock_cosmos):
test_id = str(uuid.uuid4())
cosmos_mock.return_value.CreateItem.return_value = {'id': test_id}
mock_cosmos.return_value.CreateItem.return_value = {'id': test_id}
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
returned_item = self.cosmos.upsert_document({'id': test_id})
expected_calls = [mock.call().CreateItem(
'dbs/' + self.test_database_default + '/colls/' + self.test_collection_default,
{'id': test_id})]
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)
logging.getLogger().info(returned_item)
self.assertEqual(returned_item['id'], test_id)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_upsert_document(self, cosmos_mock):
def test_upsert_document(self, mock_cosmos):
test_id = str(uuid.uuid4())
cosmos_mock.return_value.CreateItem.return_value = {'id': test_id}
mock_cosmos.return_value.CreateItem.return_value = {'id': test_id}
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
returned_item = self.cosmos.upsert_document(
{'data1': 'somedata'},
Expand All @@ -122,13 +122,13 @@ def test_upsert_document(self, cosmos_mock):
'dbs/' + self.test_database_name + '/colls/' + self.test_collection_name,
{'data1': 'somedata', 'id': test_id})]

cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)
logging.getLogger().info(returned_item)
self.assertEqual(returned_item['id'], test_id)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_insert_documents(self, cosmos_mock):
def test_insert_documents(self, mock_cosmos):
test_id1 = str(uuid.uuid4())
test_id2 = str(uuid.uuid4())
test_id3 = str(uuid.uuid4())
Expand All @@ -150,42 +150,42 @@ def test_insert_documents(self, cosmos_mock):
'dbs/' + self.test_database_default + '/colls/' + self.test_collection_default,
{'data': 'data3', 'id': test_id3})]
logging.getLogger().info(returned_item)
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_delete_database(self, cosmos_mock):
def test_delete_database(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.cosmos.delete_database(self.test_database_name)
expected_calls = [mock.call().DeleteDatabase('dbs/test_database_name')]
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_delete_database_exception(self, cosmos_mock):
def test_delete_database_exception(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.assertRaises(AirflowException, self.cosmos.delete_database, None)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_delete_container_exception(self, cosmos_mock):
def test_delete_container_exception(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.assertRaises(AirflowException, self.cosmos.delete_collection, None)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_delete_container(self, cosmos_mock):
def test_delete_container(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.cosmos.delete_collection(self.test_collection_name, self.test_database_name)
expected_calls = [mock.call().DeleteContainer('dbs/test_database_name/colls/test_collection_name')]
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)

@mock.patch('azure.cosmos.cosmos_client.CosmosClient')
def test_delete_container_default(self, cosmos_mock):
def test_delete_container_default(self, mock_cosmos):
self.cosmos = AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_test_key_id')
self.cosmos.delete_collection(self.test_collection_name)
expected_calls = [mock.call().DeleteContainer('dbs/test_database_default/colls/test_collection_name')]
cosmos_mock.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
cosmos_mock.assert_has_calls(expected_calls)
mock_cosmos.assert_any_call(self.test_end_point, {'masterKey': self.test_master_key})
mock_cosmos.assert_has_calls(expected_calls)


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions tests/contrib/hooks/test_bigquery_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def mock_poll_job_complete(job_id):
return job_id in mock_canceled_jobs


def mock_job_cancel(projectId, jobId):
def mock_job_cancel(projectId, jobId): # pylint: disable=unused-argument
mock_canceled_jobs.append(jobId)
return mock.Mock()

Expand Down Expand Up @@ -303,7 +303,7 @@ def test_run_query_sql_dialect_legacy_with_query_params(self, run_with_config):
self.assertIs(args[0]['query']['useLegacySql'], False)

@mock.patch.object(hook.BigQueryBaseCursor, 'run_with_configuration')
def test_run_query_sql_dialect_legacy_with_query_params_fails(self, run_with_config):
def test_run_query_sql_dialect_legacy_with_query_params_fails(self, mock_run_with_configuration):
cursor = hook.BigQueryBaseCursor(mock.Mock(), "project_id")
params = [{
'name': "param_name",
Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/hooks/test_datastore_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from tests.compat import mock


def mock_init(self, gcp_conn_id, delegate_to=None):
def mock_init(unused_self, unused_gcp_conn_id, unused_delegate_to=None):
pass


Expand Down
8 changes: 4 additions & 4 deletions tests/contrib/hooks/test_ftp_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ def _test_mode(self, hook_type, connection_id, expected_mode):
conn.set_pasv.assert_called_with(expected_mode)

@mock.patch("ftplib.FTP")
def test_ftp_passive_mode(self, ftp_mock):
def test_ftp_passive_mode(self, mock_ftp):
from airflow.contrib.hooks.ftp_hook import FTPHook
self._test_mode(FTPHook, "ftp_passive", True)

@mock.patch("ftplib.FTP")
def test_ftp_active_mode(self, ftp_mock):
def test_ftp_active_mode(self, mock_ftp):
from airflow.contrib.hooks.ftp_hook import FTPHook
self._test_mode(FTPHook, "ftp_active", False)

@mock.patch("ftplib.FTP_TLS")
def test_ftps_passive_mode(self, ftps_mock):
def test_ftps_passive_mode(self, mock_ftp):
from airflow.contrib.hooks.ftp_hook import FTPSHook
self._test_mode(FTPSHook, "ftp_passive", True)

@mock.patch("ftplib.FTP_TLS")
def test_ftps_active_mode(self, ftps_mock):
def test_ftps_active_mode(self, mock_ftp):
from airflow.contrib.hooks.ftp_hook import FTPSHook
self._test_mode(FTPSHook, "ftp_active", False)

Expand Down
6 changes: 3 additions & 3 deletions tests/contrib/hooks/test_grpc_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ def get_airflow_connection_with_port():


class StubClass:
def __init__(self, channel):
def __init__(self, _):
pass

def single_call(self, data):
return data

def stream_call(self, data):
def stream_call(self, data): # pylint: disable=unused-argument
return ["streaming", "call"]


class TestGrpcHook(unittest.TestCase):
def setUp(self):
self.channel_mock = mock.patch('grpc.Channel').start()

def custom_conn_func(self, connection):
def custom_conn_func(self, _):
mocked_channel = self.channel_mock.return_value
return mocked_channel

Expand Down
4 changes: 2 additions & 2 deletions tests/contrib/hooks/test_sagemaker_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test_check_valid_tuning(self, mock_check_url, mock_client):
mock_check_url.assert_called_once_with(data_url)

@mock.patch.object(SageMakerHook, 'get_client_type')
def test_conn(self, mock_get_client):
def test_conn(self, mock_get_client_type):
hook = SageMakerHook(aws_conn_id='sagemaker_test_conn_id')
self.assertEqual(hook.aws_conn_id, 'sagemaker_test_conn_id')

Expand Down Expand Up @@ -367,7 +367,7 @@ def test_training_throws_error_when_failed_with_wait(

@mock.patch.object(SageMakerHook, 'check_tuning_config')
@mock.patch.object(SageMakerHook, 'get_conn')
def test_create_tuning_job(self, mock_client, mock_check_tuning):
def test_create_tuning_job(self, mock_client, mock_check_tuning_config):
mock_session = mock.Mock()
attrs = {'create_hyper_parameter_tuning_job.return_value':
test_arn_return}
Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/hooks/test_segment_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UnitTestSegmentHook(SegmentHook):
def get_conn(self):
return conn

def get_connection(self, connection_id):
def get_connection(self, _):
return conn

self.test_hook = UnitTestSegmentHook(segment_conn_id=TEST_CONN_ID)
Expand Down
Loading