mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
refactor: Fix lint on superset/utils/core.py (#10120)
* Fix lint on superset/utils/core.py * black * mypy * Fix some missing renames
This commit is contained in:
@@ -357,7 +357,7 @@ class RequestAccessTests(SupersetTestCase):
|
||||
|
||||
session.commit()
|
||||
|
||||
@mock.patch("superset.utils.core.send_MIME_email")
|
||||
@mock.patch("superset.utils.core.send_mime_email")
|
||||
def test_approve(self, mock_send_mime):
|
||||
if app.config["ENABLE_ACCESS_REQUEST"]:
|
||||
session = db.session
|
||||
|
||||
@@ -38,7 +38,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
def setUp(self):
|
||||
app.config["smtp_ssl"] = False
|
||||
|
||||
@mock.patch("superset.utils.core.send_MIME_email")
|
||||
@mock.patch("superset.utils.core.send_mime_email")
|
||||
def test_send_smtp(self, mock_send_mime):
|
||||
attachment = tempfile.NamedTemporaryFile()
|
||||
attachment.write(b"attachment")
|
||||
@@ -58,7 +58,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
mimeapp = MIMEApplication("attachment")
|
||||
assert msg.get_payload()[-1].get_payload() == mimeapp.get_payload()
|
||||
|
||||
@mock.patch("superset.utils.core.send_MIME_email")
|
||||
@mock.patch("superset.utils.core.send_mime_email")
|
||||
def test_send_smtp_data(self, mock_send_mime):
|
||||
utils.send_email_smtp(
|
||||
"to", "subject", "content", app.config, data={"1.txt": b"data"}
|
||||
@@ -75,7 +75,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
mimeapp = MIMEApplication("data")
|
||||
assert msg.get_payload()[-1].get_payload() == mimeapp.get_payload()
|
||||
|
||||
@mock.patch("superset.utils.core.send_MIME_email")
|
||||
@mock.patch("superset.utils.core.send_mime_email")
|
||||
def test_send_smtp_inline_images(self, mock_send_mime):
|
||||
image = read_fixture("sample.png")
|
||||
utils.send_email_smtp(
|
||||
@@ -93,7 +93,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
mimeapp = MIMEImage(image)
|
||||
assert msg.get_payload()[-1].get_payload() == mimeapp.get_payload()
|
||||
|
||||
@mock.patch("superset.utils.core.send_MIME_email")
|
||||
@mock.patch("superset.utils.core.send_mime_email")
|
||||
def test_send_bcc_smtp(self, mock_send_mime):
|
||||
attachment = tempfile.NamedTemporaryFile()
|
||||
attachment.write(b"attachment")
|
||||
@@ -124,7 +124,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
mock_smtp.return_value = mock.Mock()
|
||||
mock_smtp_ssl.return_value = mock.Mock()
|
||||
msg = MIMEMultipart()
|
||||
utils.send_MIME_email("from", "to", msg, app.config, dryrun=False)
|
||||
utils.send_mime_email("from", "to", msg, app.config, dryrun=False)
|
||||
mock_smtp.assert_called_with(app.config["SMTP_HOST"], app.config["SMTP_PORT"])
|
||||
assert mock_smtp.return_value.starttls.called
|
||||
mock_smtp.return_value.login.assert_called_with(
|
||||
@@ -141,7 +141,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
app.config["SMTP_SSL"] = True
|
||||
mock_smtp.return_value = mock.Mock()
|
||||
mock_smtp_ssl.return_value = mock.Mock()
|
||||
utils.send_MIME_email("from", "to", MIMEMultipart(), app.config, dryrun=False)
|
||||
utils.send_mime_email("from", "to", MIMEMultipart(), app.config, dryrun=False)
|
||||
assert not mock_smtp.called
|
||||
mock_smtp_ssl.assert_called_with(
|
||||
app.config["SMTP_HOST"], app.config["SMTP_PORT"]
|
||||
@@ -154,7 +154,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
app.config["SMTP_PASSWORD"] = None
|
||||
mock_smtp.return_value = mock.Mock()
|
||||
mock_smtp_ssl.return_value = mock.Mock()
|
||||
utils.send_MIME_email("from", "to", MIMEMultipart(), app.config, dryrun=False)
|
||||
utils.send_mime_email("from", "to", MIMEMultipart(), app.config, dryrun=False)
|
||||
assert not mock_smtp_ssl.called
|
||||
mock_smtp.assert_called_with(app.config["SMTP_HOST"], app.config["SMTP_PORT"])
|
||||
assert not mock_smtp.login.called
|
||||
@@ -162,7 +162,7 @@ class EmailSmtpTest(SupersetTestCase):
|
||||
@mock.patch("smtplib.SMTP_SSL")
|
||||
@mock.patch("smtplib.SMTP")
|
||||
def test_send_mime_dryrun(self, mock_smtp, mock_smtp_ssl):
|
||||
utils.send_MIME_email("from", "to", MIMEMultipart(), app.config, dryrun=True)
|
||||
utils.send_mime_email("from", "to", MIMEMultipart(), app.config, dryrun=True)
|
||||
assert not mock_smtp.called
|
||||
assert not mock_smtp_ssl.called
|
||||
|
||||
|
||||
Reference in New Issue
Block a user