mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
chore: enable lint PT009 'use regular assert over self.assert.*' (#30521)
This commit is contained in:
committed by
GitHub
parent
1f013055d2
commit
a849c29288
@@ -39,7 +39,7 @@ class TestEventLogger(unittest.TestCase):
|
||||
# unmodified object
|
||||
obj = DBEventLogger()
|
||||
res = get_event_logger_from_cfg_value(obj)
|
||||
self.assertIs(obj, res)
|
||||
assert obj is res
|
||||
|
||||
def test_config_class_deprecation(self):
|
||||
# test that assignment of a class object to EVENT_LOGGER is correctly
|
||||
@@ -51,7 +51,7 @@ class TestEventLogger(unittest.TestCase):
|
||||
res = get_event_logger_from_cfg_value(DBEventLogger)
|
||||
|
||||
# class is instantiated and returned
|
||||
self.assertIsInstance(res, DBEventLogger)
|
||||
assert isinstance(res, DBEventLogger)
|
||||
|
||||
def test_raises_typeerror_if_not_abc(self):
|
||||
# test that assignment of non AbstractEventLogger derived type raises
|
||||
@@ -71,19 +71,16 @@ class TestEventLogger(unittest.TestCase):
|
||||
with app.test_request_context("/superset/dashboard/1/?myparam=foo"):
|
||||
result = test_func()
|
||||
payload = mock_log.call_args[1]
|
||||
self.assertEqual(result, 1)
|
||||
self.assertEqual(
|
||||
payload["records"],
|
||||
[
|
||||
{
|
||||
"myparam": "foo",
|
||||
"path": "/superset/dashboard/1/",
|
||||
"url_rule": "/superset/dashboard/<dashboard_id_or_slug>/",
|
||||
"object_ref": test_func.__qualname__,
|
||||
}
|
||||
],
|
||||
)
|
||||
self.assertGreaterEqual(payload["duration_ms"], 50)
|
||||
assert result == 1
|
||||
assert payload["records"] == [
|
||||
{
|
||||
"myparam": "foo",
|
||||
"path": "/superset/dashboard/1/",
|
||||
"url_rule": "/superset/dashboard/<dashboard_id_or_slug>/",
|
||||
"object_ref": test_func.__qualname__,
|
||||
}
|
||||
]
|
||||
assert payload["duration_ms"] >= 50
|
||||
|
||||
@patch.object(DBEventLogger, "log")
|
||||
def test_log_this_with_extra_payload(self, mock_log):
|
||||
@@ -98,19 +95,16 @@ class TestEventLogger(unittest.TestCase):
|
||||
with app.test_request_context():
|
||||
result = test_func(1, karg1=2) # pylint: disable=no-value-for-parameter
|
||||
payload = mock_log.call_args[1]
|
||||
self.assertEqual(result, 2)
|
||||
self.assertEqual(
|
||||
payload["records"],
|
||||
[
|
||||
{
|
||||
"foo": "bar",
|
||||
"path": "/",
|
||||
"karg1": 2,
|
||||
"object_ref": test_func.__qualname__,
|
||||
}
|
||||
],
|
||||
)
|
||||
self.assertGreaterEqual(payload["duration_ms"], 100)
|
||||
assert result == 2
|
||||
assert payload["records"] == [
|
||||
{
|
||||
"foo": "bar",
|
||||
"path": "/",
|
||||
"karg1": 2,
|
||||
"object_ref": test_func.__qualname__,
|
||||
}
|
||||
]
|
||||
assert payload["duration_ms"] >= 100
|
||||
|
||||
@patch("superset.utils.core.g", spec={})
|
||||
@freeze_time("Jan 14th, 2020", auto_tick_seconds=15)
|
||||
@@ -141,19 +135,16 @@ class TestEventLogger(unittest.TestCase):
|
||||
with logger(action="foo", engine="bar"):
|
||||
pass
|
||||
|
||||
self.assertEquals(
|
||||
logger.records,
|
||||
[
|
||||
{
|
||||
"records": [{"path": "/", "engine": "bar"}],
|
||||
"database_id": None,
|
||||
"user_id": 2,
|
||||
"duration": 15000,
|
||||
"curated_payload": {},
|
||||
"curated_form_data": {},
|
||||
}
|
||||
],
|
||||
)
|
||||
assert logger.records == [
|
||||
{
|
||||
"records": [{"path": "/", "engine": "bar"}],
|
||||
"database_id": None,
|
||||
"user_id": 2,
|
||||
"duration": 15000,
|
||||
"curated_payload": {},
|
||||
"curated_form_data": {},
|
||||
}
|
||||
]
|
||||
|
||||
@patch("superset.utils.core.g", spec={})
|
||||
def test_context_manager_log_with_context(self, mock_g):
|
||||
@@ -188,25 +179,22 @@ class TestEventLogger(unittest.TestCase):
|
||||
payload_override={"engine": "sqlite"},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
logger.records,
|
||||
[
|
||||
{
|
||||
"records": [
|
||||
{
|
||||
"path": "/",
|
||||
"object_ref": {"baz": "food"},
|
||||
"payload_override": {"engine": "sqlite"},
|
||||
}
|
||||
],
|
||||
"database_id": None,
|
||||
"user_id": 2,
|
||||
"duration": 5558756000,
|
||||
"curated_payload": {},
|
||||
"curated_form_data": {},
|
||||
}
|
||||
],
|
||||
)
|
||||
assert logger.records == [
|
||||
{
|
||||
"records": [
|
||||
{
|
||||
"path": "/",
|
||||
"object_ref": {"baz": "food"},
|
||||
"payload_override": {"engine": "sqlite"},
|
||||
}
|
||||
],
|
||||
"database_id": None,
|
||||
"user_id": 2,
|
||||
"duration": 5558756000,
|
||||
"curated_payload": {},
|
||||
"curated_form_data": {},
|
||||
}
|
||||
]
|
||||
|
||||
@patch("superset.utils.core.g", spec={})
|
||||
def test_log_with_context_user_null(self, mock_g):
|
||||
|
||||
Reference in New Issue
Block a user