fix: flaky test for dashboard changed on (#19483)

This commit is contained in:
Yongjie Zhao 2022-04-01 16:47:56 +08:00 committed by GitHub
parent d954c3df86
commit a2e921bd03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -17,11 +17,9 @@
# isort:skip_file
"""Unit tests for Superset"""
import json
from datetime import datetime
from io import BytesIO
from zipfile import is_zipfile, ZipFile
import humanize
import prison
import pytest
import yaml
@ -803,7 +801,6 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
Dashboard API: Test get charts changed on
"""
admin = self.get_user("admin")
start_changed_on = datetime.now()
chart = self.insert_chart("foo_a", [admin.id], 1, description="ZY_bar")
self.login(username="admin")
@ -817,9 +814,9 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
rv = self.get_assert_metric(uri, "get_list")
self.assertEqual(rv.status_code, 200)
data = json.loads(rv.data.decode("utf-8"))
self.assertEqual(
data["result"][0]["changed_on_delta_humanized"],
humanize.naturaltime(datetime.now() - start_changed_on),
assert data["result"][0]["changed_on_delta_humanized"] in (
"now",
"a second ago",
)
# rollback changes