kevinhongzl commented on code in PR #76963:
URL: https://github.com/apache/airflow/pull/76963#discussion_r4684619114


##########
airflow-core/tests/unit/models/test_revoked_token.py:
##########
@@ -45,59 +52,55 @@ def test_revoke_inserts_row(self):
         assert arg.jti == "test-jti-123"
         assert arg.exp == exp
 
-    def test_is_revoked_returns_true(self):
-        """Test that a revoked JTI is detected."""
-        mock_session = MagicMock()
-        mock_session.scalar.return_value = True
-        result = RevokedToken.is_revoked("known-jti", session=mock_session)
-        assert result is True
 
-    def test_is_revoked_returns_false(self):
-        """Test that an unknown JTI returns False."""
-        mock_session = MagicMock()
-        mock_session.scalar.return_value = False
-        result = RevokedToken.is_revoked("unknown-jti", session=mock_session)
-        assert result is False
+FROZEN_NOW = datetime(2026, 11, 1, tzinfo=UTC)
+JWT_EXPIRATION_TIME = 3600
+CLEANUP_INTERVAL = JWT_EXPIRATION_TIME * 2  # mirrors _maybe_cleanup_expired
+LAST_CLEANUP_TIME = 4000.0
+
+
[email protected]_test
[email protected]
+class TestRevokedTokenAsync:
+    @pytest.fixture(autouse=True)
+    def seed_revoked_tokens(self, session, time_machine):
+        time_machine.move_to(FROZEN_NOW, tick=False)
+        clear_db_revoked_tokens()
+        session.add_all(
+            [
+                RevokedToken(jti="revoked-jti", exp=FROZEN_NOW + 
timedelta(days=1)),
+                RevokedToken(jti="expired-jti", exp=FROZEN_NOW - 
timedelta(days=1)),
+            ]
+        )
+        session.commit()
+        yield
+        clear_db_revoked_tokens()
+
+    @pytest.mark.parametrize(("jti", "expected"), [("revoked-jti", True), 
("unknown-jti", False)])
+    async def test_is_revoked_async(self, jti, expected):
+        with assert_queries_count(0, include_async_engine=False):
+            assert await RevokedToken.is_revoked_async(jti) is expected

Review Comment:
   One question: is it fine if we run real db queries here instead of using a 
mock session?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to