|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +# you may not use this file except in compliance with the License. |
| 3 | +# You may obtain a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +# See the License for the specific language governing permissions and |
| 11 | +# limitations under the License. |
| 12 | + |
| 13 | +import json |
| 14 | + |
| 15 | +from pretend import call, call_recorder |
| 16 | + |
| 17 | +from warehouse.cli import tuf |
| 18 | + |
| 19 | + |
| 20 | +class TestTUF: |
| 21 | + def test_bootstrap(self, cli, monkeypatch): |
| 22 | + task_id = "123456" |
| 23 | + server = "rstuf.api" |
| 24 | + payload = ["foo"] |
| 25 | + |
| 26 | + post = call_recorder(lambda *a: task_id) |
| 27 | + wait = call_recorder(lambda *a: None) |
| 28 | + monkeypatch.setattr(tuf, "post_bootstrap", post) |
| 29 | + monkeypatch.setattr(tuf, "wait_for_success", wait) |
| 30 | + |
| 31 | + result = cli.invoke( |
| 32 | + tuf.bootstrap, args=["--api-server", server, "-"], input=json.dumps(payload) |
| 33 | + ) |
| 34 | + |
| 35 | + assert result.exit_code == 0 |
| 36 | + |
| 37 | + assert post.calls == [call(server, payload)] |
| 38 | + assert wait.calls == [call(server, task_id)] |
0 commit comments