|
19 | 19 | import pytest |
20 | 20 |
|
21 | 21 | from twine import exceptions |
| 22 | +from twine import repository |
22 | 23 | from twine import settings |
23 | 24 |
|
24 | 25 |
|
@@ -76,11 +77,44 @@ def test_settings_transforms_repository_config_non_pypi(write_config_file): |
76 | 77 | assert s.identity is None |
77 | 78 | assert s.username == "someusername" |
78 | 79 | assert s.password == "password" |
79 | | - assert s.cacert is None |
80 | 80 | assert s.client_cert is None |
81 | 81 | assert s.disable_progress_bar is False |
82 | 82 |
|
83 | 83 |
|
| 84 | +def test_settings_verify_feature_compatibility() -> None: |
| 85 | + s = settings.Settings(skip_existing=True) |
| 86 | + s.repository_config = {"repository": repository.WAREHOUSE} |
| 87 | + try: |
| 88 | + s.verify_feature_capability() |
| 89 | + except exceptions.UnsupportedConfiguration as unexpected_exc: |
| 90 | + pytest.fail( |
| 91 | + "Expected feature capability to work with production PyPI" |
| 92 | + f" but got {unexpected_exc!r}" |
| 93 | + ) |
| 94 | + |
| 95 | + s.repository_config["repository"] = repository.TEST_WAREHOUSE |
| 96 | + try: |
| 97 | + s.verify_feature_capability() |
| 98 | + except exceptions.UnsupportedConfiguration as unexpected_exc: |
| 99 | + pytest.fail( |
| 100 | + "Expected feature capability to work with TestPyPI but got" |
| 101 | + f" {unexpected_exc!r}" |
| 102 | + ) |
| 103 | + |
| 104 | + s.repository_config["repository"] = "https://not-really-pypi.example.com/legacy" |
| 105 | + with pytest.raises(exceptions.UnsupportedConfiguration): |
| 106 | + s.verify_feature_capability() |
| 107 | + |
| 108 | + s.skip_existing = False |
| 109 | + try: |
| 110 | + s.verify_feature_capability() |
| 111 | + except exceptions.UnsupportedConfiguration as unexpected_exc: |
| 112 | + pytest.fail( |
| 113 | + "Expected an exception only when --skip-existing is provided" |
| 114 | + f" but got {unexpected_exc!r}" |
| 115 | + ) |
| 116 | + |
| 117 | + |
84 | 118 | @pytest.mark.parametrize( |
85 | 119 | "verbose, log_level", [(True, logging.INFO), (False, logging.WARNING)] |
86 | 120 | ) |
|
0 commit comments