|
| 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', allow_stderr_warning=True) |
| 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, 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( |
| 35 | + 'index', 'versions', 'pip', '--pre', allow_stderr_warning=True) |
| 36 | + assert 'Available versions:' in output.stdout |
| 37 | + assert ( |
| 38 | + '20.2.3, 20.2.2, 20.2.1, 20.2, 20.2b1, 20.1.1, 20.1, 20.1b1, 20.0.2' |
| 39 | + ', 20.0.1, 19.3.1, 19.3, 19.2.3, 19.2.2, 19.2.1, 19.2, 19.1.1' |
| 40 | + ', 19.1, 19.0.3, 19.0.2, 19.0.1, 19.0, 18.1, 18.0, 10.0.1, 10.0.0, ' |
| 41 | + '10.0.0b2, 10.0.0b1, 9.0.3, 9.0.2, 9.0.1, 9.0.0, 8.1.2, 8.1.1, ' |
| 42 | + '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, ' |
| 43 | + '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, ' |
| 44 | + '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, ' |
| 45 | + '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,' |
| 46 | + ' 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, ' |
| 47 | + '0.6.2, 0.6.1, 0.6, 0.5.1, 0.5, 0.4, 0.3.1, ' |
| 48 | + '0.3, 0.2.1, 0.2' in output.stdout |
| 49 | + ) |
| 50 | + |
| 51 | + |
| 52 | +@pytest.mark.network |
| 53 | +def test_list_all_versions_returns_no_matches_found_when_name_not_exact(): |
| 54 | + """ |
| 55 | + Test that non exact name do not match |
| 56 | + """ |
| 57 | + command = create_command('index') |
| 58 | + cmdline = "versions pand" |
| 59 | + with command.main_context(): |
| 60 | + options, args = command.parse_args(cmdline.split()) |
| 61 | + status = command.run(options, args) |
| 62 | + assert status == ERROR |
| 63 | + |
| 64 | + |
| 65 | +@pytest.mark.network |
| 66 | +def test_list_all_versions_returns_matches_found_when_name_is_exact(): |
| 67 | + """ |
| 68 | + Test that exact name matches |
| 69 | + """ |
| 70 | + command = create_command('index') |
| 71 | + cmdline = "versions pandas" |
| 72 | + with command.main_context(): |
| 73 | + options, args = command.parse_args(cmdline.split()) |
| 74 | + status = command.run(options, args) |
| 75 | + assert status == SUCCESS |
0 commit comments