| 1 |
#!/usr/bin/env python3 |
| 2 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 3 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
from cylc.flow.exceptions import ClientError |
| 19 |
|
| 20 |
|
| 21 |
async def test_show(flow, scheduler, start, rakiura, monkeypatch): |
| 22 |
"""Test "cylc show" support in Tui.""" |
| 23 |
id_ = flow({ |
| 24 |
'scheduling': { |
| 25 |
'graph': { |
| 26 |
'R1': 'foo' |
| 27 |
}, |
| 28 |
}, |
| 29 |
'runtime': { |
| 30 |
'foo': { |
| 31 |
'meta': { |
| 32 |
'title': 'Foo', |
| 33 |
'description': 'The first metasyntactic variable.' |
| 34 |
}, |
| 35 |
}, |
| 36 |
}, |
| 37 |
}, name='one') |
| 38 |
schd = scheduler(id_) |
| 39 |
async with start(schd): |
| 40 |
await schd.update_data_structure() |
| 41 |
|
| 42 |
with rakiura(size='80,40') as rk: |
| 43 |
rk.user_input('down', 'right') |
| 44 |
rk.wait_until_loaded(schd.tokens.id) |
| 45 |
|
| 46 |
# select a task |
| 47 |
rk.user_input('down', 'down', 'enter') |
| 48 |
|
| 49 |
# select the "show" context option |
| 50 |
rk.user_input(*(['down'] * 8), 'enter') |
| 51 |
rk.compare_screenshot( |
| 52 |
'success', |
| 53 |
'the show output should be displayed', |
| 54 |
) |
| 55 |
|
| 56 |
# make it look like "cylc show" failed |
| 57 |
def cli_cmd_fail(*args, **kwargs): |
| 58 |
raise ClientError(':(') |
| 59 |
monkeypatch.setattr( |
| 60 |
'cylc.flow.tui.data.cli_cmd', |
| 61 |
cli_cmd_fail, |
| 62 |
) |
| 63 |
|
| 64 |
# select the "show" context option |
| 65 |
rk.user_input('q', 'enter', *(['down'] * 8), 'enter') |
| 66 |
rk.compare_screenshot( |
| 67 |
'fail', |
| 68 |
'the error should be displayed', |
| 69 |
) |