File: test_config.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 (28 lines) | stat: -rw-r--r-- 728 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
from __future__ import annotations

import os

from vdirsyncer.cli.config import _resolve_conflict_via_command
from vdirsyncer.vobject import Item


def test_conflict_resolution_command():
    def check_call(command):
        command, a_tmp, b_tmp = command
        assert command == os.path.expanduser("~/command")
        with open(a_tmp) as f:
            assert f.read() == a.raw
        with open(b_tmp) as f:
            assert f.read() == b.raw

        with open(b_tmp, "w") as f:
            f.write(a.raw)

    a = Item("UID:AAAAAAA")
    b = Item("UID:BBBBBBB")
    assert (
        _resolve_conflict_via_command(
            a, b, ["~/command"], "a", "b", _check_call=check_call
        ).raw
        == a.raw
    )