mirror of
https://github.com/apache/superset.git
synced 2026-05-21 15:55:10 +00:00
test(charts): use discriminating timestamp pair for #27500 regression
Per @codeant-ai's review: the original now/2-days pair would let a string- based sort pass the assertion, since 'n' > '2' lexically. Switched to "3 hours ago" vs "5 hours ago" — lexical desc puts "5..." first while timestamp desc must put "3..." first, so the two orderings actually disagree and a regression to string-based sorting would fail the test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1255,9 +1255,16 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
chart_newer = self.insert_chart(
|
||||
"regression_27500_newer", [admin.id], 1, description="z"
|
||||
)
|
||||
# Use timestamps whose humanized strings sort DIFFERENTLY from their
|
||||
# real timestamps under a naive lexical sort. "3 hours ago" vs
|
||||
# "5 hours ago": lexical-desc puts "5..." first (older), but
|
||||
# timestamp-desc must put "3..." first (newer). If the API ever
|
||||
# accidentally sorts by the humanized text instead of the column,
|
||||
# this test fails. (Pairs like "now"/"2 days ago" don't discriminate
|
||||
# because 'n' > '2' lexically agrees with newest-first.)
|
||||
now = datetime.utcnow()
|
||||
chart_older.changed_on = now - timedelta(days=2)
|
||||
chart_newer.changed_on = now
|
||||
chart_older.changed_on = now - timedelta(hours=5)
|
||||
chart_newer.changed_on = now - timedelta(hours=3)
|
||||
db.session.commit()
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user