-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
test_show.py
88 lines (67 loc) · 2.05 KB
/
test_show.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from cleo.testers.command_tester import CommandTester
from poetry.config.source import Source
from poetry.poetry import Poetry
from tests.types import CommandTesterFactory
@pytest.fixture
def tester(
command_tester_factory: CommandTesterFactory,
poetry_with_source: Poetry,
add_multiple_sources: None,
) -> CommandTester:
return command_tester_factory("source show", poetry=poetry_with_source)
def test_source_show_simple(tester: CommandTester):
tester.execute("")
expected = """\
name : existing
url : https://existing.com
default : no
secondary : no
name : one
url : https://one.com
default : no
secondary : no
name : two
url : https://two.com
default : no
secondary : no
""".splitlines()
assert [
line.strip() for line in tester.io.fetch_output().strip().splitlines()
] == expected
assert tester.status_code == 0
def test_source_show_one(tester: CommandTester, source_one: Source):
tester.execute(f"{source_one.name}")
expected = """\
name : one
url : https://one.com
default : no
secondary : no
""".splitlines()
assert [
line.strip() for line in tester.io.fetch_output().strip().splitlines()
] == expected
assert tester.status_code == 0
def test_source_show_two(tester: CommandTester, source_one: Source, source_two: Source):
tester.execute(f"{source_one.name} {source_two.name}")
expected = """\
name : one
url : https://one.com
default : no
secondary : no
name : two
url : https://two.com
default : no
secondary : no
""".splitlines()
assert [
line.strip() for line in tester.io.fetch_output().strip().splitlines()
] == expected
assert tester.status_code == 0
def test_source_show_error(tester: CommandTester):
tester.execute("error")
assert tester.io.fetch_error().strip() == "No source found with name(s): error"
assert tester.status_code == 1