Created
February 12, 2019 22:51
-
-
Save davidemoro/2e376aac92901589ead815d46add7c10 to your computer and use it in GitHub Desktop.
websocketd test with pytest-play using YAML files
This file contains 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
#!/bin/bash | |
while read line | |
do | |
echo "$line" | |
done |
This file contains 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
$ docker run --rm -it -v $(pwd):/src --network host davidemoro/pytest-play --variables variables.yml | |
========================================================= test session starts ========================================================= | |
platform linux -- Python 3.6.8, pytest-3.10.1, py-1.7.0, pluggy-0.8.1 | |
rootdir: /src, inifile: | |
plugins: variables-1.7.1, splinter-2.0.0, pypom-navigation-2.0.2, play-2.0.1 | |
collected 2 items | |
test_websocket.yml .. [100%] | |
========================================================== warnings summary =========================================================== | |
test_websocket.yml::test_websocket.yml0 | |
/usr/local/lib/python3.6/site-packages/_pytest/fixtures.py:828: RemovedInPytest4Warning: Fixture "tmpdir" called directly. Fixtures are not meant to be called directly, are created automatically when test functions request them as parameters. See https://docs.pytest.org/en/latest/fixture.html for more information. | |
res = fixturefunc(**kwargs) | |
-- Docs: https://docs.pytest.org/en/latest/warnings.html | |
================================================ 2 passed, 1 warnings in 2.38 seconds ================================================= |
This file contains 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
#!/bin/bash | |
docker run --rm -it -v $(pwd):/src --network host davidemoro/pytest-play --variables variables.yml |
This file contains 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
#!/bin/bash | |
./websocketd --port=8081 ./echo_ws.sh |
This file contains 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
test_data: | |
- data: hello | |
- data: world | |
--- | |
- comment: connect to websocket url | |
provider: play_websocket | |
type: connect | |
options: | |
url: "$websocket_url" | |
timeout: 5 | |
- comment: send some data to websocket server | |
provider: play_websocket | |
type: send | |
url: "$websocket_url" | |
payload: $data | |
- comment: receive response (echo) | |
provider: play_websocket | |
type: recv | |
url: "$websocket_url" | |
variable: data | |
variable_expression: results | |
assertion: variables['data'] == '$data' |
This file contains 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
--- | |
pytest-play: | |
websocket_url: ws://0.0.0.0:8081/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment