Skip to content
Snippets Groups Projects
Commit 76ff252a authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

[cmp_tool_integration_test.py] Fix python test times

DeprecationWarning: datetime.datetime.utcnow() is deprecated and
scheduled for removal in a future version. Use timezone-aware objects to
represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
parent 8e4036bc
Branches
Tags
1 merge request!33Fix cmp_tool chunk compression entity header
...@@ -10,6 +10,7 @@ from pathlib import Path ...@@ -10,6 +10,7 @@ from pathlib import Path
from datetime import datetime from datetime import datetime
from datetime import timedelta from datetime import timedelta
from datetime import timezone
EXIT_FAILURE = 1 EXIT_FAILURE = 1
...@@ -78,7 +79,7 @@ def del_directory(directoryPath): ...@@ -78,7 +79,7 @@ def del_directory(directoryPath):
def cuc_timestamp(now): def cuc_timestamp(now):
epoch = datetime(2020, 1, 1) epoch = datetime(2020, 1, 1, tzinfo=timezone.utc)
timestamp = (now - epoch).total_seconds() timestamp = (now - epoch).total_seconds()
cuc_coarse = int( math.floor(timestamp) * 256 * 256) cuc_coarse = int( math.floor(timestamp) * 256 * 256)
...@@ -447,9 +448,9 @@ def test_compression_diff(): ...@@ -447,9 +448,9 @@ def test_compression_diff():
assert(header['cmp_ent_size']['value'] == IMAGETTE_HEADER_SIZE+3) assert(header['cmp_ent_size']['value'] == IMAGETTE_HEADER_SIZE+3)
assert(header['original_size']['value'] == 10) assert(header['original_size']['value'] == 10)
# todo # todo
assert(header['start_time']['value'] < cuc_timestamp(datetime.utcnow())) assert(header['start_time']['value'] < cuc_timestamp(datetime.now(timezone.utc)))
# todo # todo
assert(header['end_timestamp']['value'] < cuc_timestamp(datetime.utcnow())) assert(header['end_timestamp']['value'] < cuc_timestamp(datetime.now(timezone.utc)))
assert(header['data_type']['value'] == 1) assert(header['data_type']['value'] == 1)
assert(header['cmp_mode_used']['value'] == 2) assert(header['cmp_mode_used']['value'] == 2)
# assert(header['model_value_used']['value'] == 8) # assert(header['model_value_used']['value'] == 8)
...@@ -582,9 +583,9 @@ def test_model_compression(): ...@@ -582,9 +583,9 @@ def test_model_compression():
assert(header['cmp_ent_size']['value'] == IMAGETTE_ADAPTIVE_HEADER_SIZE+2) assert(header['cmp_ent_size']['value'] == IMAGETTE_ADAPTIVE_HEADER_SIZE+2)
assert(header['original_size']['value'] == 10) assert(header['original_size']['value'] == 10)
# todo # todo
assert(header['start_time']['value'] < cuc_timestamp(datetime.utcnow())) assert(header['start_time']['value'] < cuc_timestamp(datetime.now(timezone.utc)))
#todo #todo
assert(header['end_timestamp']['value'] < cuc_timestamp(datetime.utcnow())) assert(header['end_timestamp']['value'] < cuc_timestamp(datetime.now(timezone.utc)))
assert(header['data_type']['value'] == DATA_TYPE_IMAGETTE_ADAPTIVE) assert(header['data_type']['value'] == DATA_TYPE_IMAGETTE_ADAPTIVE)
assert(header['cmp_mode_used']['value'] == 3) assert(header['cmp_mode_used']['value'] == 3)
assert(header['model_value_used']['value'] == int(cfg['model_value'])) assert(header['model_value_used']['value'] == int(cfg['model_value']))
...@@ -691,9 +692,9 @@ def test_raw_mode_compression(): ...@@ -691,9 +692,9 @@ def test_raw_mode_compression():
assert(header['cmp_ent_size']['value'] == GENERIC_HEADER_SIZE+10) assert(header['cmp_ent_size']['value'] == GENERIC_HEADER_SIZE+10)
assert(header['original_size']['value'] == 10) assert(header['original_size']['value'] == 10)
# todo # todo
assert(header['start_time']['value'] < cuc_timestamp(datetime.utcnow())) assert(header['start_time']['value'] < cuc_timestamp(datetime.now(timezone.utc)))
#todo #todo
assert(header['end_timestamp']['value'] < cuc_timestamp(datetime.utcnow())) assert(header['end_timestamp']['value'] < cuc_timestamp(datetime.now(timezone.utc)))
assert(header['data_type']['value'] == 1+0x8000) assert(header['data_type']['value'] == 1+0x8000)
# assert(header['cmp_mode_used']['value'] == 2) # assert(header['cmp_mode_used']['value'] == 2)
# assert(header['model_value_used']['value'] == 8) # assert(header['model_value_used']['value'] == 8)
...@@ -1017,8 +1018,8 @@ def test_sample_used_is_to_big(): ...@@ -1017,8 +1018,8 @@ def test_sample_used_is_to_big():
cmp_ent_size = IMAGETTE_HEADER_SIZE + len(cmp_data)//2 cmp_ent_size = IMAGETTE_HEADER_SIZE + len(cmp_data)//2
original_size = 0xE # wrong original_size correct is 0xA original_size = 0xE # wrong original_size correct is 0xA
start_time = cuc_timestamp(datetime.utcnow()) start_time = cuc_timestamp(datetime.now(timezone.utc))
end_time = cuc_timestamp(datetime.utcnow()) end_time = cuc_timestamp(datetime.now(timezone.utc))
data_type = 1 data_type = 1
cmp_mode_used = 2 cmp_mode_used = 2
...@@ -1083,8 +1084,8 @@ def test_cmp_entity_not_4_byte_aligned(): ...@@ -1083,8 +1084,8 @@ def test_cmp_entity_not_4_byte_aligned():
cmp_ent_size = IMAGETTE_HEADER_SIZE + len(cmp_data)//2 cmp_ent_size = IMAGETTE_HEADER_SIZE + len(cmp_data)//2
original_size = 0xC original_size = 0xC
start_time = cuc_timestamp(datetime.utcnow()) start_time = cuc_timestamp(datetime.now(timezone.utc))
end_time = cuc_timestamp(datetime.utcnow()) end_time = cuc_timestamp(datetime.now(timezone.utc))
data_type = 1 data_type = 1
cmp_mode_used = 2 cmp_mode_used = 2
...@@ -1177,8 +1178,8 @@ def test_header_read_in(): ...@@ -1177,8 +1178,8 @@ def test_header_read_in():
cmp_ent_size = IMAGETTE_HEADER_SIZE + len(cmp_data)//2 cmp_ent_size = IMAGETTE_HEADER_SIZE + len(cmp_data)//2
original_size = 0xA original_size = 0xA
start_time = cuc_timestamp(datetime.utcnow()) start_time = cuc_timestamp(datetime.now(timezone.utc))
end_time = cuc_timestamp(datetime.utcnow()) end_time = cuc_timestamp(datetime.now(timezone.utc))
data_type = 1 data_type = 1
cmp_mode_used = 2 cmp_mode_used = 2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment