Created
October 8, 2021 20:42
-
-
Save robintw/b3733b6f67d0d2299b409ad04e2f84f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def test_select_platform_type(test_datastore): | |
# Test application in a dummy session. | |
input = DummyInput() | |
# output = DummyOutput() | |
output = None | |
with create_app_session(output=output, input=input): | |
gui = MaintenanceGUI(test_datastore) | |
# Run the application. | |
# We run it by scheduling the run_async coroutine in the current event | |
# loop. | |
task = asyncio.create_task(gui.app.run_async()) | |
ready_event = asyncio.Event() | |
gui.app.after_render += lambda _: ready_event.set() | |
await ready_event.wait() | |
# Send F1 to open the help dialog | |
gui.app.key_processor.feed(KeyPress(Keys.F1)) | |
gui.app.key_processor.process_keys() | |
await asyncio.sleep(2) | |
# Check the help dialog has opened | |
assert isinstance(gui.current_dialog, HelpDialog) | |
# Send Tab and Enter to exit the help dialog | |
gui.app.key_processor.feed(KeyPress(Keys.Tab, "\t")) | |
gui.app.key_processor.feed(KeyPress(Keys.ControlM, "\r")) | |
gui.app.key_processor.process_keys() | |
await asyncio.sleep(2) | |
# Check no dialog is open | |
assert gui.current_dialog is None | |
# Send ESC to open the 'Do you want to exit?' dialog | |
gui.app.key_processor.feed(KeyPress(Keys.Escape)) | |
gui.app.key_processor.process_keys() | |
await asyncio.sleep(2) | |
# Send Enter to say yes | |
gui.app.key_processor.feed(KeyPress(Keys.ControlM, "\r")) | |
gui.app.key_processor.process_keys() | |
# Wait for the application to properly terminate. | |
await task |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment