コード例 #1
0
def test_remove_old(dict_tmpdir, monkeypatch):
    # given
    monkeypatch.setattr(dictcli, 'download_dictionary',
                        lambda _url, dest: py.path.local(dest).ensure())  # pylint: disable=no-member
    for f in ['pl-PL-2-0.bdic', polish().remote_path, english().remote_path]:
        (dict_tmpdir / f).ensure()

    # when
    dictcli.remove_old(langs())

    # then
    installed_files = [f.basename for f in dict_tmpdir.listdir()]
    expected_files = [polish().remote_path, english().remote_path]
    assert sorted(installed_files) == sorted(expected_files)
コード例 #2
0
def test_remove_old(tmpdir, monkeypatch):
    # given
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    monkeypatch.setattr(
        dictcli, 'download_dictionary',
        lambda _url, dest: py.path.local(dest).ensure())  # pylint: disable=no-member
    for f in ['pl-PL-2-0.bdic', polish().remote_path, english().remote_path]:
        (tmpdir / f).ensure()

    # when
    dictcli.remove_old(langs())

    # then
    installed_files = [f.basename for f in tmpdir.listdir()]
    expected_files = [polish().remote_path, english().remote_path]
    assert sorted(installed_files) == sorted(expected_files)
コード例 #3
0
def test_remove_old(dict_tmp_path, monkeypatch):
    # given
    monkeypatch.setattr(
        dictcli, 'download_dictionary',
        lambda _url, dest: pathlib.Path(dest).touch())
    for f in ['pl-PL-2-0.bdic',
              polish().remote_filename,
              english().remote_filename]:
        (dict_tmp_path / f).touch()

    # when
    dictcli.remove_old(langs())

    # then
    installed_files = [f.name for f in dict_tmp_path.glob('*')]
    expected_files = [polish().remote_filename, english().remote_filename]
    assert sorted(installed_files) == sorted(expected_files)