示例#1
0
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)
    ]
示例#2
0
def test_list_logs_filtering(tmp_path: Path) -> None:
    # GIVEN
    srcdir = tmp_path / "source"
    srcdir.mkdir()
    srcdir.joinpath("one.igc").touch()
    srcdir.joinpath("two.igc").touch()

    tgtdir = tmp_path / "target"
    tgtdir.joinpath("openvario", "igc").mkdir(parents=True)
    tgtdir.joinpath("openvario", "igc", "two.igc").touch()

    dl = DownloaderImpl(str(srcdir), str(tgtdir))

    # WHEN, THEN
    logs = dl.list_logs(DownloadFilter(new=True))
    assert [x.name for x in logs] == ["one.igc"]

    # Files are listed in reverse-chronological order
    logs = dl.list_logs(DownloadFilter(new=False))
    assert [x.name for x in logs] == ["two.igc", "one.igc"]

    logs = dl.list_logs(DownloadFilter(new=True, igc=False, nmea=True))
    assert [x.name for x in logs] == []

    # Type is detected by extensions, that are case-insensitive
    srcdir.joinpath("three.NMEA").touch()
    logs = dl.list_logs(DownloadFilter(new=True, igc=False, nmea=True))
    assert [x.name for x in logs] == ["three.NMEA"]