[AIRFLOW-4215] Replace mock with unittest.mock (#5292)

This commit is contained in:
Chao-Han Tsai 2019-05-17 06:40:03 -07:00 коммит произвёл Jarek Potiuk
Родитель ba46d87f93
Коммит 577f893672
117 изменённых файлов: 136 добавлений и 141 удалений

Просмотреть файл

@ -260,7 +260,6 @@ devel = [
'flake8>=3.6.0', 'flake8>=3.6.0',
'freezegun', 'freezegun',
'jira', 'jira',
'mock;python_version<"3.3"',
'mongomock', 'mongomock',
'moto==1.3.5', 'moto==1.3.5',
'nose', 'nose',

Просмотреть файл

@ -21,7 +21,7 @@ import json
import unittest import unittest
from freezegun import freeze_time from freezegun import freeze_time
from mock import patch from unittest.mock import patch
from airflow import AirflowException from airflow import AirflowException
from airflow import models from airflow import models

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
import json import json

Просмотреть файл

@ -23,7 +23,7 @@ import sys
import unittest import unittest
from datetime import datetime, timedelta, time from datetime import datetime, timedelta, time
from mock import patch, Mock, MagicMock from unittest.mock import patch, Mock, MagicMock
from time import sleep from time import sleep
import psutil import psutil
import pytz import pytz

Просмотреть файл

@ -20,7 +20,7 @@
import json import json
import unittest import unittest
from collections import namedtuple from collections import namedtuple
from mock import patch from unittest.mock import patch
from airflow import configuration from airflow import configuration
from airflow.models import Connection from airflow.models import Connection

Просмотреть файл

@ -22,7 +22,7 @@ import unittest
from typing import List from typing import List
from google.auth.exceptions import GoogleAuthError from google.auth.exceptions import GoogleAuthError
import mock from unittest import mock
from googleapiclient.errors import HttpError from googleapiclient.errors import HttpError
from airflow.contrib.hooks import bigquery_hook as hook from airflow.contrib.hooks import bigquery_hook as hook

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import json import json
import mock from unittest import mock
import unittest import unittest
from airflow.exceptions import AirflowException from airflow.exceptions import AirflowException

Просмотреть файл

@ -21,7 +21,7 @@
import unittest import unittest
from airflow.contrib.hooks.datastore_hook import DatastoreHook from airflow.contrib.hooks.datastore_hook import DatastoreHook
from mock import call, patch from unittest.mock import call, patch
from tests.compat import mock from tests.compat import mock

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import six import six
import unittest import unittest

Просмотреть файл

@ -18,7 +18,7 @@
import json import json
import unittest import unittest
import mock from unittest import mock
import requests import requests
from google.auth.exceptions import GoogleAuthError from google.auth.exceptions import GoogleAuthError
from googleapiclient.discovery import build_from_document from googleapiclient.discovery import build_from_document

Просмотреть файл

@ -20,7 +20,7 @@
import imaplib import imaplib
import unittest import unittest
from mock import Mock, patch, mock_open from unittest.mock import Mock, patch, mock_open
from airflow import configuration, AirflowException from airflow import configuration, AirflowException
from airflow.contrib.hooks.imap_hook import ImapHook from airflow.contrib.hooks.imap_hook import ImapHook

Просмотреть файл

@ -21,8 +21,8 @@
import unittest import unittest
import json import json
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from airflow import configuration from airflow import configuration
from airflow.hooks.jdbc_hook import JdbcHook from airflow.hooks.jdbc_hook import JdbcHook

Просмотреть файл

@ -20,8 +20,8 @@
import unittest import unittest
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from airflow import configuration from airflow import configuration
from airflow.contrib.hooks.jira_hook import JiraHook from airflow.contrib.hooks.jira_hook import JiraHook

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from airflow.contrib.hooks.pinot_hook import PinotDbApiHook from airflow.contrib.hooks.pinot_hook import PinotDbApiHook

Просмотреть файл

@ -21,7 +21,7 @@
import unittest import unittest
import pandas as pd import pandas as pd
from mock import patch, Mock from unittest.mock import patch, Mock
from simple_salesforce import Salesforce from simple_salesforce import Salesforce
from airflow.contrib.hooks.salesforce_hook import SalesforceHook from airflow.contrib.hooks.salesforce_hook import SalesforceHook

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from airflow import configuration, AirflowException from airflow import configuration, AirflowException

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
import shutil import shutil
import os import os

Просмотреть файл

@ -20,12 +20,12 @@
import json import json
from requests.exceptions import MissingSchema from requests.exceptions import MissingSchema
import unittest import unittest
from unittest import mock
from airflow import configuration from airflow import configuration
from airflow.models import Connection from airflow.models import Connection
from airflow.utils import db from airflow.utils import db
from airflow.contrib.hooks.slack_webhook_hook import SlackWebhookHook from airflow.contrib.hooks.slack_webhook_hook import SlackWebhookHook
from tests.compat import mock
class TestSlackWebhookHook(unittest.TestCase): class TestSlackWebhookHook(unittest.TestCase):
@ -104,8 +104,9 @@ class TestSlackWebhookHook(unittest.TestCase):
# Then # Then
self.assertEqual(self.expected_message, message) self.assertEqual(self.expected_message, message)
@mock.patch('requests.Session')
@mock.patch('requests.Request') @mock.patch('requests.Request')
def test_url_generated_by_http_conn_id(self, request_mock): def test_url_generated_by_http_conn_id(self, request_mock, session_mock):
hook = SlackWebhookHook(http_conn_id='slack-webhook-url') hook = SlackWebhookHook(http_conn_id='slack-webhook-url')
try: try:
hook.execute() hook.execute()
@ -119,8 +120,9 @@ class TestSlackWebhookHook(unittest.TestCase):
) )
request_mock.reset_mock() request_mock.reset_mock()
@mock.patch('requests.Session')
@mock.patch('requests.Request') @mock.patch('requests.Request')
def test_url_generated_by_endpoint(self, request_mock): def test_url_generated_by_endpoint(self, request_mock, session_mock):
hook = SlackWebhookHook(webhook_token=self.expected_url) hook = SlackWebhookHook(webhook_token=self.expected_url)
try: try:
hook.execute() hook.execute()
@ -134,8 +136,9 @@ class TestSlackWebhookHook(unittest.TestCase):
) )
request_mock.reset_mock() request_mock.reset_mock()
@mock.patch('requests.Session')
@mock.patch('requests.Request') @mock.patch('requests.Request')
def test_url_generated_by_http_conn_id_and_endpoint(self, request_mock): def test_url_generated_by_http_conn_id_and_endpoint(self, request_mock, session_mock):
hook = SlackWebhookHook(http_conn_id='slack-webhook-host', hook = SlackWebhookHook(http_conn_id='slack-webhook-host',
webhook_token='B000/XXX') webhook_token='B000/XXX')
try: try:

Просмотреть файл

@ -19,7 +19,7 @@
# #
import os import os
import mock from unittest import mock
import unittest import unittest
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization

Просмотреть файл

@ -22,7 +22,7 @@ import six
import unittest import unittest
from itertools import dropwhile from itertools import dropwhile
from mock import patch, call from unittest.mock import patch, call
from airflow import configuration from airflow import configuration
from airflow.models import Connection from airflow.models import Connection

Просмотреть файл

@ -23,7 +23,7 @@ import unittest
from airflow import configuration, AirflowException from airflow import configuration, AirflowException
from airflow.models import Connection from airflow.models import Connection
from airflow.utils import db from airflow.utils import db
from mock import patch, call from unittest.mock import patch, call
from airflow.contrib.hooks.spark_submit_hook import SparkSubmitHook from airflow.contrib.hooks.spark_submit_hook import SparkSubmitHook

Просмотреть файл

@ -28,7 +28,7 @@ from airflow.exceptions import AirflowException
from airflow.models import Connection from airflow.models import Connection
from airflow.utils import db from airflow.utils import db
from mock import patch, call from unittest.mock import patch, call
from io import StringIO from io import StringIO

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow import AirflowException from airflow import AirflowException
from airflow.contrib.hooks.winrm_hook import WinRMHook from airflow.contrib.hooks.winrm_hook import WinRMHook

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
import mock from unittest import mock
from airflow.hooks.zendesk_hook import ZendeskHook from airflow.hooks.zendesk_hook import ZendeskHook
from zdesk import RateLimitError from zdesk import RateLimitError

Просмотреть файл

@ -22,7 +22,7 @@ import unittest
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.operators.aws_sqs_publish_operator import SQSPublishOperator from airflow.contrib.operators.aws_sqs_publish_operator import SQSPublishOperator
from airflow.utils import timezone from airflow.utils import timezone
from mock import MagicMock from unittest.mock import MagicMock
from moto import mock_sqs from moto import mock_sqs
from airflow.contrib.hooks.aws_sqs_hook import SQSHook from airflow.contrib.hooks.aws_sqs_hook import SQSHook

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
import mock from unittest import mock
from builtins import str from builtins import str
from airflow.contrib.operators.cassandra_to_gcs import \ from airflow.contrib.operators.cassandra_to_gcs import \
CassandraToGoogleCloudStorageOperator CassandraToGoogleCloudStorageOperator

Просмотреть файл

@ -39,8 +39,8 @@ from tests.compat import mock
from copy import deepcopy from copy import deepcopy
from mock import MagicMock, Mock from unittest.mock import MagicMock, Mock
from mock import patch from unittest.mock import patch
TASK_ID = 'test-dataproc-operator' TASK_ID = 'test-dataproc-operator'
CLUSTER_NAME = 'test-cluster-name' CLUSTER_NAME = 'test-cluster-name'

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
import mock from unittest import mock
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.operators.dingding_operator import DingdingOperator from airflow.contrib.operators.dingding_operator import DingdingOperator
@ -68,4 +68,4 @@ class TestDingdingOperator(unittest.TestCase):
self._config['at_mobiles'], self._config['at_mobiles'],
self._config['at_all'] self._config['at_all']
) )
mock_hook.return_value.send.assert_called_once() mock_hook.return_value.send.assert_called_once_with()

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from airflow import DAG, configuration from airflow import DAG, configuration

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from datetime import timedelta from datetime import timedelta
from mock import MagicMock, patch from unittest.mock import MagicMock, patch
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.operators.emr_add_steps_operator import EmrAddStepsOperator from airflow.contrib.operators.emr_add_steps_operator import EmrAddStepsOperator

Просмотреть файл

@ -21,7 +21,7 @@
import unittest import unittest
from datetime import timedelta from datetime import timedelta
from mock import MagicMock, patch from unittest.mock import MagicMock, patch
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.operators.emr_create_job_flow_operator import EmrCreateJobFlowOperator from airflow.contrib.operators.emr_create_job_flow_operator import EmrCreateJobFlowOperator

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
from mock import MagicMock, patch from unittest.mock import MagicMock, patch
from airflow import configuration from airflow import configuration
from airflow.contrib.operators.emr_terminate_job_flow_operator import EmrTerminateJobFlowOperator from airflow.contrib.operators.emr_terminate_job_flow_operator import EmrTerminateJobFlowOperator

Просмотреть файл

@ -22,7 +22,7 @@ import json
import unittest import unittest
import datetime import datetime
import mock from unittest import mock
import pandas as pd import pandas as pd
from airflow import configuration, DAG from airflow import configuration, DAG

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow.contrib.operators.imap_attachment_to_s3_operator import ImapAttachmentToS3Operator from airflow.contrib.operators.imap_attachment_to_s3_operator import ImapAttachmentToS3Operator

Просмотреть файл

@ -20,8 +20,8 @@
import unittest import unittest
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.operators.jira_operator import JiraOperator from airflow.contrib.operators.jira_operator import JiraOperator

Просмотреть файл

@ -21,7 +21,7 @@ import unittest
import httplib2 import httplib2
from googleapiclient.errors import HttpError from googleapiclient.errors import HttpError
from mock import ANY, patch from unittest.mock import ANY, patch
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.operators.mlengine_operator import (MLEngineBatchPredictionOperator, from airflow.contrib.operators.mlengine_operator import (MLEngineBatchPredictionOperator,

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from airflow import configuration, AirflowException from airflow import configuration, AirflowException

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from airflow.contrib.operators.sns_publish_operator import SnsPublishOperator from airflow.contrib.operators.sns_publish_operator import SnsPublishOperator

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
from airflow.contrib.operators.vertica_operator import VerticaOperator from airflow.contrib.operators.vertica_operator import VerticaOperator

Просмотреть файл

@ -19,7 +19,7 @@
import datetime import datetime
import mock from unittest import mock
import unittest import unittest
from airflow import DAG, configuration from airflow import DAG, configuration

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
from airflow.contrib.operators.winrm_operator import WinRMOperator from airflow.contrib.operators.winrm_operator import WinRMOperator

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow import DAG from airflow import DAG
from airflow import configuration from airflow import configuration

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow.contrib.sensors.celery_queue_sensor import CeleryQueueSensor from airflow.contrib.sensors.celery_queue_sensor import CeleryQueueSensor

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
import datetime import datetime
from dateutil.tz import tzlocal from dateutil.tz import tzlocal
from mock import MagicMock, patch from unittest.mock import MagicMock, patch
from airflow import configuration from airflow import configuration
from airflow.contrib.sensors.emr_job_flow_sensor import EmrJobFlowSensor from airflow.contrib.sensors.emr_job_flow_sensor import EmrJobFlowSensor

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from datetime import datetime from datetime import datetime
from mock import MagicMock, patch from unittest.mock import MagicMock, patch
from dateutil.tz import tzlocal from dateutil.tz import tzlocal
from airflow import configuration, AirflowException from airflow import configuration, AirflowException

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from ftplib import error_perm from ftplib import error_perm
from mock import MagicMock from unittest.mock import MagicMock
from airflow.contrib.hooks.ftp_hook import FTPHook from airflow.contrib.hooks.ftp_hook import FTPHook
from airflow.contrib.sensors.ftp_sensor import FTPSensor from airflow.contrib.sensors.ftp_sensor import FTPSensor

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import patch, Mock from unittest.mock import patch, Mock
from airflow import configuration from airflow import configuration
from airflow.contrib.sensors.imap_attachment_sensor import ImapAttachmentSensor from airflow.contrib.sensors.imap_attachment_sensor import ImapAttachmentSensor

Просмотреть файл

@ -20,8 +20,8 @@
import unittest import unittest
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.sensors.jira_sensor import JiraTicketSensor from airflow.contrib.sensors.jira_sensor import JiraTicketSensor

Просмотреть файл

@ -21,7 +21,7 @@
import unittest import unittest
from datetime import datetime from datetime import datetime
from mock import patch from unittest.mock import patch
from airflow.contrib.sensors.qubole_sensor import QuboleFileSensor, QubolePartitionSensor from airflow.contrib.sensors.qubole_sensor import QuboleFileSensor, QubolePartitionSensor
from airflow.exceptions import AirflowException from airflow.exceptions import AirflowException

Просмотреть файл

@ -23,7 +23,7 @@ from airflow import DAG, configuration
from airflow.contrib.sensors.redis_pub_sub_sensor import RedisPubSubSensor from airflow.contrib.sensors.redis_pub_sub_sensor import RedisPubSubSensor
from airflow.utils import timezone from airflow.utils import timezone
from airflow.contrib.hooks.redis_hook import RedisHook from airflow.contrib.hooks.redis_hook import RedisHook
from mock import patch, call, MagicMock from unittest.mock import patch, call, MagicMock
DEFAULT_DATE = timezone.datetime(2017, 1, 1) DEFAULT_DATE = timezone.datetime(2017, 1, 1)

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
from mock import patch from unittest.mock import patch
from paramiko import SFTP_NO_SUCH_FILE, SFTP_FAILURE from paramiko import SFTP_NO_SUCH_FILE, SFTP_FAILURE
from airflow.contrib.sensors.sftp_sensor import SFTPSensor from airflow.contrib.sensors.sftp_sensor import SFTPSensor

Просмотреть файл

@ -22,7 +22,7 @@ import unittest
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.contrib.sensors.aws_sqs_sensor import SQSSensor from airflow.contrib.sensors.aws_sqs_sensor import SQSSensor
from airflow.utils import timezone from airflow.utils import timezone
from mock import patch, MagicMock from unittest.mock import patch, MagicMock
from airflow.exceptions import AirflowException from airflow.exceptions import AirflowException
from moto import mock_sqs from moto import mock_sqs
from airflow.contrib.hooks.aws_sqs_hook import SQSHook from airflow.contrib.hooks.aws_sqs_hook import SQSHook

Просмотреть файл

@ -16,7 +16,7 @@
# KIND, either express or implied. See the License for the # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
from airflow.contrib.task_runner.cgroup_task_runner import CgroupTaskRunner from airflow.contrib.task_runner.cgroup_task_runner import CgroupTaskRunner

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
GCP_PROJECT_ID_HOOK_UNIT_TEST = 'example-project' GCP_PROJECT_ID_HOOK_UNIT_TEST = 'example-project'

Просмотреть файл

@ -23,8 +23,8 @@ from airflow.contrib.utils import mlengine_operator_utils
from airflow.exceptions import AirflowException from airflow.exceptions import AirflowException
from airflow.version import version from airflow.version import version
from mock import ANY from unittest.mock import ANY
from mock import patch from unittest.mock import patch
DEFAULT_DATE = datetime.datetime(2017, 6, 6) DEFAULT_DATE = datetime.datetime(2017, 6, 6)
TEST_VERSION = 'v{}'.format(version.replace('.', '-').replace('+', '-')) TEST_VERSION = 'v{}'.format(version.replace('.', '-').replace('+', '-'))

Просмотреть файл

@ -21,7 +21,7 @@ import json
import unittest import unittest
import doctest import doctest
import mock from unittest import mock
import multiprocessing import multiprocessing
import os import os
import pickle # type: ignore import pickle # type: ignore

Просмотреть файл

@ -22,7 +22,7 @@ import unittest
import contextlib import contextlib
from multiprocessing import Pool from multiprocessing import Pool
import mock from unittest import mock
from celery import Celery from celery import Celery
from celery import states as celery_states from celery import states as celery_states

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from airflow.hooks.dbapi_hook import DbApiHook from airflow.hooks.dbapi_hook import DbApiHook

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
from mock import MagicMock, patch from unittest.mock import MagicMock, patch
import requests import requests
import requests_mock import requests_mock
import unittest import unittest

Просмотреть файл

@ -26,7 +26,7 @@ import sys
import unittest import unittest
from collections import OrderedDict from collections import OrderedDict
import mock from unittest import mock
import pandas as pd import pandas as pd
from hmsclient import HMSClient from hmsclient import HMSClient

Просмотреть файл

@ -76,8 +76,9 @@ class TestHttpHook(unittest.TestCase):
self.assertEqual(resp.text, '{"status":{"status": 200}}') self.assertEqual(resp.text, '{"status":{"status": 200}}')
@requests_mock.mock() @requests_mock.mock()
@mock.patch('requests.Session')
@mock.patch('requests.Request') @mock.patch('requests.Request')
def test_get_request_with_port(self, m, request_mock): def test_get_request_with_port(self, m, request_mock, session_mock):
from requests.exceptions import MissingSchema from requests.exceptions import MissingSchema
with mock.patch( with mock.patch(

Просмотреть файл

@ -19,7 +19,7 @@
# #
import json import json
import mock from unittest import mock
import unittest import unittest
import MySQLdb.cursors import MySQLdb.cursors

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile

Просмотреть файл

@ -18,10 +18,10 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow.hooks.presto_hook import PrestoHook from airflow.hooks.presto_hook import PrestoHook

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import tempfile import tempfile
import unittest import unittest

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from hdfs import HdfsError from hdfs import HdfsError
from mock import patch, call from unittest.mock import patch, call
from airflow.hooks.webhdfs_hook import WebHDFSHook, AirflowWebHDFSHookException from airflow.hooks.webhdfs_hook import WebHDFSHook, AirflowWebHDFSHookException
from airflow.models.connection import Connection from airflow.models.connection import Connection

Просмотреть файл

@ -21,7 +21,7 @@ import unittest
from collections import namedtuple from collections import namedtuple
from cryptography.fernet import Fernet from cryptography.fernet import Fernet
from mock import patch from unittest.mock import patch
from parameterized import parameterized from parameterized import parameterized
from airflow.models import Connection, crypto from airflow.models import Connection, crypto

Просмотреть файл

@ -28,7 +28,7 @@ from tempfile import NamedTemporaryFile
import jinja2 import jinja2
import pendulum import pendulum
import six import six
from mock import patch from unittest.mock import patch
from airflow import models, settings, configuration from airflow import models, settings, configuration
from airflow.exceptions import AirflowException, AirflowDagCycleException from airflow.exceptions import AirflowException, AirflowDagCycleException

Просмотреть файл

@ -24,7 +24,7 @@ import textwrap
import unittest import unittest
from tempfile import mkdtemp, NamedTemporaryFile from tempfile import mkdtemp, NamedTemporaryFile
from mock import patch, ANY from unittest.mock import patch, ANY
from airflow import models, configuration from airflow import models, configuration
from airflow.models import DagModel, DagBag, TaskInstance as TI from airflow.models import DagModel, DagBag, TaskInstance as TI
@ -128,7 +128,7 @@ class DagBagTest(unittest.TestCase):
test the loading of a DAG from within a zip file that skips another file because test the loading of a DAG from within a zip file that skips another file because
it doesn't have "airflow" and "DAG" it doesn't have "airflow" and "DAG"
""" """
from mock import Mock from unittest.mock import Mock
with patch('airflow.models.DagBag.log') as log_mock: with patch('airflow.models.DagBag.log') as log_mock:
log_mock.info = Mock() log_mock.info = Mock()
test_zip_path = os.path.join(TEST_DAGS_FOLDER, "test_zip.zip") test_zip_path = os.path.join(TEST_DAGS_FOLDER, "test_zip.zip")

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow import settings from airflow import settings
from airflow.models import KubeResourceVersion, KubeWorkerIdentifier from airflow.models import KubeResourceVersion, KubeWorkerIdentifier

Просмотреть файл

@ -21,7 +21,7 @@ import datetime
import unittest import unittest
import pendulum import pendulum
from mock import patch, Mock from unittest.mock import patch, Mock
from airflow import settings from airflow import settings
from airflow.models import DAG, TaskInstance as TI from airflow.models import DAG, TaskInstance as TI

Просмотреть файл

@ -24,7 +24,7 @@ import urllib
import pendulum import pendulum
from freezegun import freeze_time from freezegun import freeze_time
from mock import patch, mock_open from unittest.mock import patch, mock_open
from parameterized import parameterized from parameterized import parameterized
from airflow import models, settings, configuration from airflow import models, settings, configuration

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from cryptography.fernet import Fernet from cryptography.fernet import Fernet
from mock import patch from unittest.mock import patch
from airflow import settings from airflow import settings
from airflow.models import crypto, Variable from airflow.models import crypto, Variable

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import datetime import datetime
import mock from unittest import mock
import unittest import unittest
from airflow import configuration, DAG from airflow import configuration, DAG

Просмотреть файл

@ -21,7 +21,7 @@ import datetime
import os import os
import unittest import unittest
import mock from unittest import mock
import nose import nose
from airflow import DAG, configuration, operators from airflow import DAG, configuration, operators

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from collections import OrderedDict from collections import OrderedDict
from mock import patch from unittest.mock import patch
from airflow import AirflowException from airflow import AirflowException
from airflow.operators.hive_stats_operator import HiveStatsCollectionOperator from airflow.operators.hive_stats_operator import HiveStatsCollectionOperator

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import patch, PropertyMock from unittest.mock import patch, PropertyMock
from airflow.operators.hive_to_mysql import HiveToMySqlTransfer from airflow.operators.hive_to_mysql import HiveToMySqlTransfer
from airflow.utils.operator_helpers import context_to_airflow_vars from airflow.utils.operator_helpers import context_to_airflow_vars

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import patch, PropertyMock, Mock from unittest.mock import patch, PropertyMock, Mock
from airflow.operators.hive_to_samba_operator import Hive2SambaOperator from airflow.operators.hive_to_samba_operator import Hive2SambaOperator
from airflow.utils.operator_helpers import context_to_airflow_vars from airflow.utils.operator_helpers import context_to_airflow_vars

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow.operators.jdbc_operator import JdbcOperator from airflow.operators.jdbc_operator import JdbcOperator

Просмотреть файл

@ -24,7 +24,7 @@ try:
import pymssql import pymssql
except ImportError: except ImportError:
pymssql = None pymssql = None
from mock import patch, PropertyMock, Mock from unittest.mock import patch, PropertyMock, Mock
from airflow.operators.mssql_to_hive import MsSqlToHiveTransfer from airflow.operators.mssql_to_hive import MsSqlToHiveTransfer

Просмотреть файл

@ -23,7 +23,7 @@ from airflow.utils import timezone
from collections import OrderedDict from collections import OrderedDict
import os import os
import mock from unittest import mock
import unittest import unittest
configuration.load_test_config() configuration.load_test_config()

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow.operators.papermill_operator import PapermillOperator from airflow.operators.papermill_operator import PapermillOperator

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import patch from unittest.mock import patch
from airflow.operators.presto_to_mysql import PrestoToMySqlTransfer from airflow.operators.presto_to_mysql import PrestoToMySqlTransfer

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from boto3.session import Session from boto3.session import Session

Просмотреть файл

@ -27,7 +27,7 @@ import unittest
from tempfile import mkdtemp from tempfile import mkdtemp
import boto3 import boto3
import mock from unittest import mock
from moto import mock_s3 from moto import mock_s3
from airflow.exceptions import AirflowException from airflow.exceptions import AirflowException

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import unittest import unittest
from boto3.session import Session from boto3.session import Session

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from mock import Mock from unittest.mock import Mock
import airflow import airflow
from airflow.exceptions import AirflowException from airflow.exceptions import AirflowException

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
from mock import Mock from unittest.mock import Mock
from airflow import DAG, configuration, settings from airflow import DAG, configuration, settings
from airflow.exceptions import (AirflowSensorTimeout, AirflowException, from airflow.exceptions import (AirflowSensorTimeout, AirflowException,

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
import requests import requests
from mock import patch from unittest.mock import patch
from airflow import DAG, configuration from airflow import DAG, configuration
from airflow.exceptions import AirflowException, AirflowSensorTimeout from airflow.exceptions import AirflowException, AirflowSensorTimeout

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
from parameterized import parameterized from parameterized import parameterized

Просмотреть файл

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
from airflow.sensors.s3_prefix_sensor import S3PrefixSensor from airflow.sensors.s3_prefix_sensor import S3PrefixSensor

Просмотреть файл

@ -16,7 +16,7 @@
# KIND, either express or implied. See the License for the # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import unittest import unittest
from airflow import DAG from airflow import DAG

Просмотреть файл

@ -16,7 +16,7 @@
# KIND, either express or implied. See the License for the # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import os import os
import psutil import psutil
import time import time

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from airflow.stats import SafeStatsdLogger from airflow.stats import SafeStatsdLogger
from mock import Mock from unittest.mock import Mock
class TestStats(unittest.TestCase): class TestStats(unittest.TestCase):

Просмотреть файл

@ -19,7 +19,7 @@
from contextlib import ContextDecorator from contextlib import ContextDecorator
from mock import Mock from unittest.mock import Mock
from airflow import conf from airflow import conf

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
from mock import Mock from unittest.mock import Mock
from airflow.models import TaskInstance from airflow.models import TaskInstance
from airflow.ti_deps.deps.dag_ti_slots_available_dep import DagTISlotsAvailableDep from airflow.ti_deps.deps.dag_ti_slots_available_dep import DagTISlotsAvailableDep

Просмотреть файл

@ -18,7 +18,7 @@
# under the License. # under the License.
import unittest import unittest
from mock import Mock from unittest.mock import Mock
from airflow.models import TaskInstance from airflow.models import TaskInstance
from airflow.ti_deps.deps.dag_unpaused_dep import DagUnpausedDep from airflow.ti_deps.deps.dag_unpaused_dep import DagUnpausedDep

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from airflow.utils.state import State from airflow.utils.state import State
from mock import Mock, patch from unittest.mock import Mock, patch
from airflow.models import DAG, DagRun from airflow.models import DAG, DagRun
from airflow.ti_deps.deps.dagrun_exists_dep import DagrunRunningDep from airflow.ti_deps.deps.dagrun_exists_dep import DagrunRunningDep

Просмотреть файл

@ -20,7 +20,7 @@
import unittest import unittest
from datetime import timedelta from datetime import timedelta
from freezegun import freeze_time from freezegun import freeze_time
from mock import Mock from unittest.mock import Mock
from airflow.models import TaskInstance from airflow.models import TaskInstance
from airflow.ti_deps.deps.not_in_retry_period_dep import NotInRetryPeriodDep from airflow.ti_deps.deps.not_in_retry_period_dep import NotInRetryPeriodDep

Просмотреть файл

@ -19,7 +19,7 @@
import unittest import unittest
from datetime import datetime from datetime import datetime
from mock import Mock from unittest.mock import Mock
from airflow.ti_deps.deps.not_running_dep import NotRunningDep from airflow.ti_deps.deps.not_running_dep import NotRunningDep
from airflow.utils.state import State from airflow.utils.state import State

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше