Skip to content

Commit

Permalink
fix: Dashboard API flaky test (#17611)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Dec 1, 2021
1 parent 2f2e8fe commit 78c5d9a
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions tests/integration_tests/dashboards/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,29 +413,29 @@ def test_get_dashboards_changed_on(self):
from datetime import datetime
import humanize

admin = self.get_user("admin")
start_changed_on = datetime.now()
dashboard = self.insert_dashboard("title", "slug1", [admin.id])

self.login(username="admin")

arguments = {
"order_column": "changed_on_delta_humanized",
"order_direction": "desc",
}
uri = f"api/v1/dashboard/?q={prison.dumps(arguments)}"

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),
)
with freeze_time("2020-01-01T00:00:00Z"):
admin = self.get_user("admin")
dashboard = self.insert_dashboard("title", "slug1", [admin.id])

self.login(username="admin")

arguments = {
"order_column": "changed_on_delta_humanized",
"order_direction": "desc",
}
uri = f"api/v1/dashboard/?q={prison.dumps(arguments)}"

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()),
)

# rollback changes
db.session.delete(dashboard)
db.session.commit()
# rollback changes
db.session.delete(dashboard)
db.session.commit()

def test_get_dashboards_filter(self):
"""
Expand Down

0 comments on commit 78c5d9a

Please sign in to comment.