From 7a168f9a9b07d9d1a9c5daaa4abf8bb5ce039aa0 Mon Sep 17 00:00:00 2001 From: Trish Gillett-Kawamoto Date: Sun, 11 Aug 2024 10:29:59 -0600 Subject: [PATCH] Use UTC timestamp --- tap_github/authenticator.py | 4 ++-- tap_github/tests/test_authenticator.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tap_github/authenticator.py b/tap_github/authenticator.py index a54019f0..1ab3cbf0 100644 --- a/tap_github/authenticator.py +++ b/tap_github/authenticator.py @@ -3,7 +3,7 @@ import logging import time from copy import deepcopy -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from os import environ from random import choice, shuffle from typing import Any, Dict, List, Optional, Set, Tuple @@ -47,7 +47,7 @@ def __init__( def update_rate_limit(self, response_headers: Any) -> None: self.rate_limit = int(response_headers["X-RateLimit-Limit"]) self.rate_limit_remaining = int(response_headers["X-RateLimit-Remaining"]) - self.rate_limit_reset = datetime.fromtimestamp( + self.rate_limit_reset = datetime.utcfromtimestamp( int(response_headers["X-RateLimit-Reset"]) ) self.rate_limit_used = int(response_headers["X-RateLimit-Used"]) diff --git a/tap_github/tests/test_authenticator.py b/tap_github/tests/test_authenticator.py index cdce4e67..44b313d5 100644 --- a/tap_github/tests/test_authenticator.py +++ b/tap_github/tests/test_authenticator.py @@ -1,5 +1,5 @@ import re -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from unittest.mock import MagicMock, patch import pytest @@ -41,7 +41,7 @@ def test_update_rate_limit(self): assert token_manager.rate_limit == 5000 assert token_manager.rate_limit_remaining == 4999 - assert token_manager.rate_limit_reset == datetime(2013, 7, 1, 11, 47, 53) + assert token_manager.rate_limit_reset == datetime(2013, 7, 1, 17, 47, 53) assert token_manager.rate_limit_used == 1 def test_is_valid_token_successful(self):