Skip to content

Commit 2e062e0

Browse files
author
Noah Gorny
committed
tests: index: Add tests for "versions" subcommand
1 parent 05cbad3 commit 2e062e0

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

tests/functional/test_index.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import pytest
2+
3+
from pip._internal.cli.status_codes import ERROR, SUCCESS
4+
from pip._internal.commands import create_command
5+
6+
7+
@pytest.mark.network
8+
def test_list_all_versions_basic_search(script):
9+
"""
10+
End to end test of index versions command.
11+
"""
12+
output = script.pip('index', 'versions', 'pip')
13+
assert 'Available versions:' in output.stdout
14+
assert (
15+
'20.2.3, 20.2.2, 20.2.1, 20.2, 20.1.1, 20.1, 20.0.2'
16+
', 20.0.1, 20.0, 19.3.1, 19.3, 19.2.3, 19.2.2, 19.2.1, 19.2, 19.1.1'
17+
', 19.1, 19.0.3, 19.0.2, 19.0.1, 19.0, 18.1, 18.0, 10.0.1, 10.0.0, '
18+
'9.0.3, 9.0.2, 9.0.1, 9.0.0, 8.1.2, 8.1.1, '
19+
'8.1.0, 8.0.3, 8.0.2, 8.0.1, 8.0.0, 7.1.2, 7.1.1, 7.1.0, 7.0.3, '
20+
'7.0.2, 7.0.1, 7.0.0, 6.1.1, 6.1.0, 6.0.8, 6.0.7, 6.0.6, 6.0.5, '
21+
'6.0.4, 6.0.3, 6.0.2, 6.0.1, 6.0, 1.5.6, 1.5.5, 1.5.4, 1.5.3, '
22+
'1.5.2, 1.5.1, 1.5, 1.4.1, 1.4, 1.3.1, 1.3, 1.2.1, 1.2, 1.1, 1.0.2,'
23+
' 1.0.1, 1.0, 0.8.3, 0.8.2, 0.8.1, 0.8, 0.7.2, 0.7.1, 0.7, 0.6.3, '
24+
'0.6.2, 0.6.1, 0.6, 0.5.1, 0.5, 0.4, 0.3.1, '
25+
'0.3, 0.2.1, 0.2' in output.stdout
26+
)
27+
28+
29+
@pytest.mark.network
30+
def test_list_all_versions_search_with_pre(script):
31+
"""
32+
See that adding the --pre flag adds pre-releases
33+
"""
34+
output = script.pip('index', 'versions', 'pip', '--pre')
35+
assert 'Available versions:' in output.stdout
36+
assert (
37+
'20.2.3, 20.2.2, 20.2.1, 20.2, 20.2b1, 20.1.1, 20.1, 20.1b1, 20.0.2'
38+
', 20.0.1, 20.0, 19.3.1, 19.3, 19.2.3, 19.2.2, 19.2.1, 19.2, 19.1.1'
39+
', 19.1, 19.0.3, 19.0.2, 19.0.1, 19.0, 18.1, 18.0, 10.0.1, 10.0.0, '
40+
'10.0.0b2, 10.0.0b1, 9.0.3, 9.0.2, 9.0.1, 9.0.0, 8.1.2, 8.1.1, '
41+
'8.1.0, 8.0.3, 8.0.2, 8.0.1, 8.0.0, 7.1.2, 7.1.1, 7.1.0, 7.0.3, '
42+
'7.0.2, 7.0.1, 7.0.0, 6.1.1, 6.1.0, 6.0.8, 6.0.7, 6.0.6, 6.0.5, '
43+
'6.0.4, 6.0.3, 6.0.2, 6.0.1, 6.0, 1.5.6, 1.5.5, 1.5.4, 1.5.3, '
44+
'1.5.2, 1.5.1, 1.5, 1.4.1, 1.4, 1.3.1, 1.3, 1.2.1, 1.2, 1.1, 1.0.2,'
45+
' 1.0.1, 1.0, 0.8.3, 0.8.2, 0.8.1, 0.8, 0.7.2, 0.7.1, 0.7, 0.6.3, '
46+
'0.6.2, 0.6.1, 0.6, 0.5.1, 0.5, 0.4, 0.3.1, '
47+
'0.3, 0.2.1, 0.2' in output.stdout
48+
)
49+
50+
51+
@pytest.mark.network
52+
def test_list_all_versions_returns_no_matches_found_when_name_not_exact():
53+
"""
54+
Test that non exact name do not match
55+
"""
56+
command = create_command('index')
57+
cmdline = "versions pand"
58+
with command.main_context():
59+
options, args = command.parse_args(cmdline.split())
60+
status = command.run(options, args)
61+
assert status == ERROR
62+
63+
64+
@pytest.mark.network
65+
def test_list_all_versions_returns_matches_found_when_name_is_exact():
66+
"""
67+
Test that exact name matches
68+
"""
69+
command = create_command('index')
70+
cmdline = "versions pandas"
71+
with command.main_context():
72+
options, args = command.parse_args(cmdline.split())
73+
status = command.run(options, args)
74+
assert status == SUCCESS

0 commit comments

Comments
 (0)