Skip to main content

coeus

coeus is a python client implementation of the json-message protocol for remote (Tcp) integration tests.

pypi travis

Installation

coeus is meant to be added as a requirement to your python unit-test project. Simply add a reference to coeus-test.

pip install coeus-test

Getting Started

Glossary

Client: A class for connecting via TCP to the server application.

Message: A specific json format (prototcol) defining the communication.

TestEntity: An abstract concept for an entity that exists in the server application. Usually accessed via it's ID.

Client Setup

The client must connect to the server application via an IP and port. You can invoke a connection as follows:

import client

cli = client.Client(tcp_port=31203)
cli.connect()

By default, it will attempt to connect with ip: 127.0.0.1.

Commands

Commands are specific blocking calls that are sent to the server, then waits to receive a message. Every command has a response.

Commands do not handle any validation of message received from unity client.

import commands

Query Commands

query_entity_is_registered

This command asks the unity application about the state of an entity.

Usage

result = commands.query_entity_is_registered(cli, "myEntityId")

Response

{
    "type" : "query.entity.isRegistered",
    "payload": {
        "result" : true | false
    }
}

Await Commands

await_entity_registered

This command blocks until a specific state is reached for the entitiy. By default, it will block until the entity was registered. If the command exceeds the specified timeout, it continue with a failure.

Usage

// is_registered, timeout_seconds optional...
result = commands.await_entity_registered(cli, "myEntityId", is_registered=True, timeout_seconds=60)

Response

{
    "type":"await.continue",
    "payload": {
        "success":true|false
    }
}

Fetch Commands

fetch_entity

This command asks the server to serialize the TestEntity and send it.

Usage

result = commands.fetch_entity(cli, "myEntityId")

Success Response

{
    "type":"fetch.entity",
    "payload": {
        "test_entity" : {...} | null
    }
}

Invoke Commands

invoke_entity_method

This command allows the python unit-test to invoke a method on the server"s TestEntity and return the result.

Usage

parameters = {
    "statName":"score"
}
result = commands.invoke_entity_method(cli, "myEntityId", "GetPlayerStat", parameters)

In the C# code, this will look for a method with the following signature:

public int GetPlayerStat(IDynamicObject parameters)
{
    var statName = parameters.GetValue<string>("statName");
    ...

    return stat;
}

Response

{
    "type":"invoke.entity.method",
    "payload": {
        "is_error" : false,
        "error_message" : null,
        "result" : 32
    }
}

If there is a C# exception, then the error_message will contain the exceptions message.

Assertions

The commands do not validate the response from the server. To easily do this, use the assertions.

import assertions

...
# Fails assert if False returned from response...
assertions.assert_entity_is_registered(cli, "myEntityId")

# Fails if timeout exceeded...
assertions.assert_await_entity_registered(cli, "myEntityId")

# Fails if the test_entity is None...
result = assertions.assert_fetch_entity(cli, "myEntityId")

# Fails if is_error == True, AssertException with message provided...
result = assert_invoke_entity_method(cli, "myEntityId", "GetPlayerStat", ...)

Release files for coeus-test 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coeus-test 0.1.13
File Size Uploaded
coeus-test-0.1.13.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for coeus-test 0.1.13
File Interpreter ABI Platform
coeus_test-0.1.13-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 12.9 kB

Release files / coeus-test-0.1.13.tar.gz

Download URL coeus-test-0.1.13.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ddd5ae77790ece038cc47edc8feef4d6a2ff924cfe66fd2704b6a4c063ee8387
BLAKE2b-256 checksum
How to use checksums
114a370d93fa20242143093aa4d03690d53adec104cdea33f56bae6aefffbef4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3

Release files / coeus_test-0.1.13-py2.py3-none-any.whl

Download URL coeus_test-0.1.13-py2.py3-none-any.whl
Size 7.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
99dd5e99aeff21ffa773a80c9c993838c6c683fe4aa5268107c1e7b0219c2527
BLAKE2b-256 checksum
How to use checksums
e607d62b2d22fe90f555788f1ab0b7866735ea71b4bb925bd1d0978ad608dc84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3

Release history Release notifications | RSS feed

This release

0.1.13 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page