示例#1
0
 def test_get_auth_token_refreshes_if_refresh_token_and_no_expiration(
         self, monkeypatch):
     refresh_token = MagicMock()
     monkeypatch.setattr("prefect.Client._refresh_access_token",
                         refresh_token)
     client = Client(api_token="api")
     client._access_token = "access"
     client._refresh_token = "refresh"
     client._access_token_expires_at = None
     client.get_auth_token()
     assert refresh_token.called
示例#2
0
 def test_get_auth_token_doesnt_refresh_if_refresh_token_and_future_expiration(
         self, monkeypatch):
     refresh_token = MagicMock()
     monkeypatch.setattr("prefect.Client._refresh_access_token",
                         refresh_token)
     client = Client(api_token="api")
     client._access_token = "access"
     client._refresh_token = "refresh"
     client._access_token_expires_at = pendulum.now().add(minutes=10)
     assert client.get_auth_token() == "access"
     refresh_token.assert_not_called()
示例#3
0
 def test_get_auth_token_refreshes_if_refresh_token_and_expiration_within_30_seconds(
         self, monkeypatch):
     refresh_token = MagicMock()
     monkeypatch.setattr("prefect.Client._refresh_access_token",
                         refresh_token)
     client = Client(api_token="api")
     client._access_token = "access"
     client._refresh_token = "refresh"
     client._access_token_expires_at = pendulum.now().add(seconds=29)
     client.get_auth_token()
     assert refresh_token.called