Coeus-Unity
About
Coeus-Unity is a collection of commands and assertions built on coeus-test package for python. These commands support remote integration tests in Unity with the use of the C# Coeus test framework.
Contributors
Setup
Simply install the requirement into your package.
pip install coeus-test-unity
Commands
Commands offer no response validation. You can use assertions for that.
import commands
response = commands.query_transform_exists(cli, "My/Transform Hierarchy/Object (Clone)")
response = commands.query_scene_loaded(cli, "AppSetup")
response = commands.query_renderer_visible(cli, "My/Target/Object (Clone)")
response = commands.await_transform_exists(cli, "My/Transform Hierarchy/Object (Clone)")
# Waits for renderer to become not visible based on False...
response = commands.await_renderer_visible(cli, "My/Transform Hierarchy/Object (Clone)", False)
response = commands.await_scene_loaded(cli, "AppSetup")
# Finds a FieldInfo | PropertyInfo on the component and attempts to assign the value (String | Number | Boolean)
commands.assign_component_value(cli, "My/Transform/Target", "InputField", "text", "Hello World")
# Finds a FieldInfo | PropertyInfo on the component and attempts to obtain its value
value = commands.fetch_component_value(cli, "My/Transform/Target", "InputField", "text")
Assertions
Since commands only assert the response message, they don't verify the state being requested; for this we can use the assertions.
import assertions
# Fails immediately if transform doesn't exist...
assertions.assert_transform_exists(cli, "Some/Path")
# Fails immediately if scene not loaded...
assertions.assert_scene_loaded(cli, "MyScene")
# Awaits for the scene to be loaded, fails when exceeded...
assertions.assert_await_scene_loaded(cli, "MyScene")
# Awaits for a transform to exist by timeout, fails when exceeded...
assertions.assert_await_transform_exists(cli, "Some/Path", timeout_seconds=10)
# Awaits for a renderer to be visible by timeout, fails when exceeded...
assertions.assert_await_renderer_visible(cli, "Some/Path", timeout_seconds=10)
# Awaits for all transforms to exist by timeout, fails when exceeded...
assertions.assert_await_all_transforms_exist(cli, ["Some/Path1", "Some/Path2"], timeout_seconds=10)
# Awaits for any of the transforms to exist by timeout, fails when exceeded...
assertions.assert_await_any_transforms_exist(cli, ["Some/Path1", "Some/Path2"], timeout_seconds=10)
# Checks if FieldInfo | PropertyInfo on the component equals to the provided value
assertions.assert_component_value_equals(cli, "My/Transform/Target", "InputField", "text", "password")
# Awaits a FieldInfo | PropertyInfo on the component to become the provided value
assertions.assert_await_component_value_equals(cli, "My/Transform/Target", "InputField", "text", "password")
Advanced
Transform Path Variables
If your client supports variable replacement, you can simply pass them into your paths. For instance if you have different variations on transform path names based on some predictable variable, you can pass those in for replacement.
# {deviceFormfactor} is replaced in client...
assertions.assert_await_transform_exists(cli, "Kiosk-{deviceFormFactor}(Clone"), timeout_seconds=10)
Transform References
If two or more sibling transforms have the same name, the transform path is ambiguous. This makes it difficult to specify the correct transform, as the example below illustrates:
# Suppose both buttons have the same transform path: "Path/To/Menu/Button"
# Fetch button0 position using transform path
button0_position = commands.fetch_transform_screen_position(cli, "Path/To/Menu/Button")
# Can't fetch button1 position using transform path because transform path is ambiguous
button1_position = # ???
To resolve the ambiguity, you can use a transform reference, which supplements the transform path with sibling indices to yield a unique path for each transform. Use the fetch_transform command to obtain a transform reference:
# Suppose both buttons have the same transform path: "Path/To/Menu/Button"
# Obtain a transform reference
menu = commands.fetch_transform(cli, "Path/To/Menu")
# Fetch button0 position using transform reference
button0_position = commands.fetch_transform_screen_position(cli, menu.children[0])
# Fetch button1 position using transform reference
button1_position = commands.fetch_transform_screen_position(cli, menu.children[1])
Warning: Transform references are only valid as long as the transform hierarchy doesn't change. If the hierarchy changes (e.g. a transform is created or deleted, or the sibling order changes), you must call
fetch_transformagain to obtain updated transform references.
Release files for coeus-test-unity 0.1.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| coeus-test-unity-0.1.16.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| coeus_test_unity-0.1.16-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 19.8 kB
Release files / coeus-test-unity-0.1.16.tar.gz
| Download URL | coeus-test-unity-0.1.16.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e9f956995a1c087aba3622c0234fd0b52fe353d10a4ada6d2779855f8f966c2
|
|
BLAKE2b-256 checksum How to use checksums |
18c41d37e0e8824bbb7bcbc90f5fa9fc4a25a929010d2944bd26d3d417209fbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.15
|
Release files / coeus_test_unity-0.1.16-py2.py3-none-any.whl
| Download URL | coeus_test_unity-0.1.16-py2.py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b4f750b0f446b8db35106ffc76111c592fefd2296ee6289c8f324a1a82850b1f
|
|
BLAKE2b-256 checksum How to use checksums |
0560900bacdce4b4ce95d3e6b9e31ab7beadec8090df3aaf1b334b8957e3ea70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.15
|