mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02: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:
parent
7933623e93
commit
9560ed955c
@ -114,7 +114,7 @@ def get_embedded_classes(apkfile, depth=0):
|
|||||||
|
|
||||||
def _datetime_now():
|
def _datetime_now():
|
||||||
"""Get datetime.now(), using this funciton allows mocking it for testing."""
|
"""Get datetime.now(), using this funciton allows mocking it for testing."""
|
||||||
return datetime.now().astimezone()
|
return datetime.utcnow()
|
||||||
|
|
||||||
|
|
||||||
def _scanner_cachedir():
|
def _scanner_cachedir():
|
||||||
|
@ -508,13 +508,13 @@ class Test_SignatureDataController(unittest.TestCase):
|
|||||||
# check_last_updated
|
# check_last_updated
|
||||||
def test_check_last_updated_ok(self):
|
def test_check_last_updated_ok(self):
|
||||||
sdc = fdroidserver.scanner.SignatureDataController('nnn', 'fff.yml', 'https://example.com/test.json')
|
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()
|
sdc.check_last_updated()
|
||||||
|
|
||||||
def test_check_last_updated_exception_cache_outdated(self):
|
def test_check_last_updated_exception_cache_outdated(self):
|
||||||
sdc = fdroidserver.scanner.SignatureDataController('nnn', 'fff.yml', 'https://example.com/test.json')
|
sdc = fdroidserver.scanner.SignatureDataController('nnn', 'fff.yml', 'https://example.com/test.json')
|
||||||
sdc.cache_duration = timedelta(days=7)
|
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):
|
with self.assertRaises(fdroidserver.scanner.SignatureDataOutdatedException):
|
||||||
sdc.check_last_updated()
|
sdc.check_last_updated()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user