File: test_faker.py

package info (click to toggle)
scriv 1.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 600 kB
  • sloc: python: 3,880; makefile: 164
file content (62 lines) | stat: -rw-r--r-- 1,365 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Tests of tests/faker.py

Mostly error paths, since the happy paths are covered by other tests.
"""

import re

import pytest

from scriv import shell


def test_no_such_command(fake_run_command):
    assert shell.run_command("wut") == (
        False,
        "no fake command handler: ['wut']",
    )


def test_no_such_git_command(fake_git):
    assert shell.run_command("git hello") == (
        False,
        "no fake git command: ['git', 'hello']",
    )
    assert shell.run_command("git config --wut") == (
        False,
        "no fake git command: ['git', 'config', '--wut']",
    )


@pytest.mark.parametrize(
    "name",
    [
        "foo.bar",
        "foo.bar12",
        "foo.bar-",
        "foo.bar-bar",
        "foo-foo.bar",
        "section.subsection.bar",
        "section.some/sub_section!ok.bar",
    ],
)
def test_git_set_config_good_names(name, fake_git):
    val = "xyzzy plugh!?"
    fake_git.set_config(name, val)
    result = shell.run_command(f"git config --get {name}")
    assert result == (True, val + "\n")


@pytest.mark.parametrize(
    "name",
    [
        "bar",
        "foo.12bar",
        "foo.bar_bar",
        "foo_foo.bar",
    ],
)
def test_git_set_config_bad_names(name, fake_git):
    with pytest.raises(ValueError, match=re.escape(f"invalid key: {name!r}")):
        fake_git.set_config(name, "hello there")