mirror of
https://github.com/f-droid/fdroidserver.git
synced 2026-05-18 13:39:55 -04:00
avoid running into native-date object issue
Seem I ran into this issue: https://bugs.python.org/issue47228 This change tries to fix it by using utcnow insteas of astimezone.
This commit is contained in:
@@ -114,7 +114,7 @@ def get_embedded_classes(apkfile, depth=0):
|
||||
|
||||
def _datetime_now():
|
||||
"""Get datetime.now(), using this funciton allows mocking it for testing."""
|
||||
return datetime.now().astimezone()
|
||||
return datetime.utcnow()
|
||||
|
||||
|
||||
def _scanner_cachedir():
|
||||
|
||||
@@ -508,13 +508,13 @@ class Test_SignatureDataController(unittest.TestCase):
|
||||
# check_last_updated
|
||||
def test_check_last_updated_ok(self):
|
||||
sdc = fdroidserver.scanner.SignatureDataController('nnn', 'fff.yml', 'https://example.com/test.json')
|
||||
sdc.data['last_updated'] = datetime.now().astimezone().isoformat()
|
||||
sdc.data['last_updated'] = datetime.utcnow().isoformat()
|
||||
sdc.check_last_updated()
|
||||
|
||||
def test_check_last_updated_exception_cache_outdated(self):
|
||||
sdc = fdroidserver.scanner.SignatureDataController('nnn', 'fff.yml', 'https://example.com/test.json')
|
||||
sdc.cache_duration = timedelta(days=7)
|
||||
sdc.data['last_updated'] = (datetime.now().astimezone() - timedelta(days=30)).isoformat()
|
||||
sdc.data['last_updated'] = (datetime.utcnow() - timedelta(days=30)).isoformat()
|
||||
with self.assertRaises(fdroidserver.scanner.SignatureDataOutdatedException):
|
||||
sdc.check_last_updated()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user