File: test_fetchparams.py

package info (click to toggle)
vdirsyncer 0.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 944 kB
  • sloc: python: 7,380; makefile: 205; sh: 66
file content (48 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import annotations

from textwrap import dedent


def test_get_password_from_command(tmpdir, runner):
    runner.write_with_general(
        dedent(
            f"""
        [pair foobar]
        a = "foo"
        b = "bar"
        collections = ["a", "b", "c"]

        [storage foo]
        type.fetch = ["shell", "echo filesystem"]
        path = "{str(tmpdir)}/foo/"
        fileext.fetch = ["command", "echo", ".txt"]

        [storage bar]
        type = "filesystem"
        path = "{str(tmpdir)}/bar/"
        fileext.fetch = ["prompt", "Fileext for bar"]
    """
        )
    )

    foo = tmpdir.ensure("foo", dir=True)
    foo.ensure("a", dir=True)
    foo.ensure("b", dir=True)
    foo.ensure("c", dir=True)
    bar = tmpdir.ensure("bar", dir=True)
    bar.ensure("a", dir=True)
    bar.ensure("b", dir=True)
    bar.ensure("c", dir=True)

    result = runner.invoke(["discover"], input=".asdf\n")
    assert not result.exception
    status = tmpdir.join("status").join("foobar.collections").read()
    assert "foo" in status
    assert "bar" in status
    assert "asdf" not in status
    assert "txt" not in status

    foo.join("a").join("foo.txt").write("BEGIN:VCARD\nUID:foo\nEND:VCARD")
    result = runner.invoke(["sync"], input=".asdf\n")
    assert not result.exception
    assert [x.basename for x in bar.join("a").listdir()] == ["foo.asdf"]