Skip to content

Commit

Permalink
Added bracketing datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui committed Mar 4, 2023
1 parent e346cac commit fe61e9c
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_add_files(single_mission: Tuple[Mock, DataManager, Path],
main()
mock.add.assert_called_once_with(paths=bin_files, readme=False)

def test_add_files_start_stop(single_mission: Tuple[Mock, DataManager, Path],
def test_add_files_start(single_mission: Tuple[Mock, DataManager, Path],
test_data: Tuple[Path, int, int]):
"""Tests adding files
Expand All @@ -84,22 +84,41 @@ def test_add_files_start_stop(single_mission: Tuple[Mock, DataManager, Path],
test_data (Tuple[Path, int, int]): Test Data
"""
mock, _, _ = single_mission
data_dir, n_files, _ = test_data
data_dir, _, _ = test_data


bin_files = list(data_dir.glob('*.bin'))
start_time = dt.datetime.fromtimestamp(bin_files[0].stat().st_mtime)
end_time = dt.datetime.fromtimestamp(bin_files[-1].stat().st_mtime)
sleep(1)

start_time = dt.datetime.now()

args = split(f'e4edm add {data_dir.as_posix()}/*.bin '
f'--start {start_time.isoformat()}')
with patch('sys.argv', args):
main()
mock.add.assert_called_once_with(paths=[], readme=False)

def test_add_files_end(single_mission: Tuple[Mock, DataManager, Path],
test_data: Tuple[Path, int, int]):
"""Tests adding files
Args:
test_app (Tuple[Mock, DataManager, Path]): Mock App
test_data (Tuple[Path, int, int]): Test Data
"""
mock, _, _ = single_mission
data_dir, _, _ = test_data


bin_files = list(data_dir.glob('*.bin'))
sleep(1)
data_dir.joinpath(f'{n_files + 1:04d}.bin').touch()

start_time = dt.datetime.now()

args = split(f'e4edm add {data_dir.as_posix()}/*.bin '
f'--start {start_time.isoformat()} --end {end_time.isoformat()}')
f'--end {start_time.isoformat()}')
with patch('sys.argv', args):
main()
mock.add.assert_called_once_with(paths=bin_files, readme=False)

def test_add_glob(single_mission: Tuple[Mock, DataManager, Path],
test_data: Tuple[Path, int, int]):
"""Tests adding files
Expand Down

0 comments on commit fe61e9c

Please sign in to comment.