def test_list_logs_notarget(tmp_path: Path) -> None: # GIVEN srcdir = tmp_path / "source" srcdir.mkdir() srcdir.joinpath("one.igc").touch() dl = DownloaderImpl(str(srcdir), str(tmp_path / "target")) filt = DownloadFilter() # WHEN logs = dl.list_logs(filt) # THEN assert logs == [ FileInfo("one.igc", ftype=".igc", size=0, mtime=mock.ANY, downloaded=False) ]
async def test_activity_unmount( activity_testbed: LogDownloaderActivityTestbed, ) -> None: # GIVEN activity_testbed.downloader.stub_files = [ FileInfo("two.igc", ".igc", size=20000, mtime=0, downloaded=False) ] w = activity_testbed.activity.create() activity_testbed.activity.activate() # Let mount watcher detect start await asyncio.sleep(0) assert activity_testbed.mountwatcher.stub_running activity_testbed.mountwatcher.stub_mount() assert "two.igc" in _render(w) # WHEN activity_testbed.mountwatcher.stub_unmount() assert "Please insert USB storage" in _render(w)
async def test_activity_list_files( activity_testbed: LogDownloaderActivityTestbed, ) -> None: # GIVEN urwid_mock = UrwidMock() activity_testbed.downloader.stub_files = [ FileInfo("two.igc", ".igc", size=20000, mtime=0, downloaded=False) ] w = activity_testbed.activity.create() activity_testbed.activity.activate() # Let mount watcher detect start await asyncio.sleep(0) assert activity_testbed.mountwatcher.stub_running activity_testbed.mountwatcher.stub_mount() # WHEN rendered = urwid_mock.render(w) # THEN assert "two.igc" in rendered
async def test_activity_download_error( activity_testbed: LogDownloaderActivityTestbed, ) -> None: # GIVEN activity_testbed.downloader.stub_files = [ FileInfo("two.igc", ".igc", size=20000, mtime=0, downloaded=False) ] w = activity_testbed.activity.create() activity_testbed.activity.activate() activity_testbed.mountwatcher.stub_mount() activity_testbed.downloader.failing = True # WHEN _keypress(w, ["down", "enter"]) # THEN await asyncio.sleep(0) assert "0 %" in _render(w) await asyncio.sleep(0) assert "50 %" in _render(w) await asyncio.sleep(0) assert "Failed" in _render(w)
async def test_activity_download( activity_testbed: LogDownloaderActivityTestbed, ) -> None: # GIVEN urwid_mock = UrwidMock() activity_testbed.downloader.stub_files = [ FileInfo("two.igc", ".igc", size=20000, mtime=0, downloaded=False) ] w = activity_testbed.activity.create() activity_testbed.activity.activate() activity_testbed.mountwatcher.stub_mount() # WHEN urwid_mock.keypress(w, ["down", "enter"]) # THEN await asyncio.sleep(0) assert "0 %" in urwid_mock.render(w) await asyncio.sleep(0) assert "50 %" in urwid_mock.render(w) await asyncio.sleep(0) assert "100 %" in urwid_mock.render(w) await asyncio.sleep(0) assert "Done" in urwid_mock.render(w)