Skip to content

Commit 65186a1

Browse files
committed
update tests with the case when granule names cross midnight in UTC timezone
1 parent 91d40fc commit 65186a1

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

tests/test_filename_grouping.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@
22
from unittest.mock import patch
33

44
import batcher.tempo_filename_parser
5-
from batcher.tempo_filename_parser import get_batch_indices
5+
from batcher.tempo_filename_parser import get_batch_indices, get_day_in_us_central
66

77
example_filenames = [
8-
"TEMPO_HCHO_L2_V01_20130701T212354Z_S009G05.nc",
9-
"TEMPO_HCHO_L2_V01_20130701T212953Z_S009G06.nc",
10-
"TEMPO_HCHO_L2_V01_20130701T213553Z_S009G07.nc",
11-
"TEMPO_HCHO_L2_V01_20130701T215955Z_S010G01.nc",
12-
"TEMPO_HCHO_L2_V01_20130701T220554Z_S010G02.nc",
13-
"TEMPO_HCHO_L2_V01_20130701T221154Z_S010G03.nc",
8+
"TEMPO_NO2_L2_V03_20240731T235252Z_S016G04.nc",
9+
"TEMPO_NO2_L2_V03_20240731T235929Z_S016G05.nc",
10+
"TEMPO_NO2_L2_V03_20240801T000606Z_S016G06.nc",
11+
"TEMPO_NO2_L2_V03_20240801T001302Z_S017G01.nc",
12+
"TEMPO_NO2_L2_V03_20240801T001942Z_S017G02.nc",
13+
"TEMPO_NO2_L2_V03_20240801T002619Z_S017G03.nc",
14+
"TEMPO_NO2_L2_V03_20240801T233313Z_S016G01.nc",
15+
"TEMPO_NO2_L2_V03_20240801T233953Z_S016G02.nc",
16+
"TEMPO_NO2_L2_V03_20240801T234630Z_S016G03.nc",
1417
]
1518

19+
def test_timezone_conversion():
20+
utcdates = [filename.split('_')[4] for filename in example_filenames]
21+
days_in_central = [get_day_in_us_central(utcdt[0:8], utcdt[9:15]) for utcdt in utcdates]
22+
assert days_in_central == ["20240731", "20240731", "20240731", "20240731", "20240731", "20240731", "20240801", "20240801", "20240801"]
1623

1724
def test_grouping():
1825
results = get_batch_indices(example_filenames)
1926

20-
assert results == [0, 0, 0, 1, 1, 1]
27+
assert results == [0, 0, 0, 1, 1, 1, 2, 2, 2]
2128

2229

2330
def test_main_cli():
@@ -27,4 +34,4 @@ def test_main_cli():
2734
with patch.object(sys, "argv", test_args):
2835
grouped_names = batcher.tempo_filename_parser.main()
2936

30-
assert grouped_names == [example_filenames[0:3], example_filenames[3:6]]
37+
assert grouped_names == [example_filenames[0:3], example_filenames[3:6], example_filenames[6:9]]

0 commit comments

Comments
 (0)