None
Project description
volttron-testing
Prerequisites
- Python >= 3.8
Installation
Create a virtual environment
python -m venv env
Activate the environment
source env/bin/activate
Install volttron-testing
# Installs volttron and volttron-testing
pip install volttron-testing
Developing with TestServer
The following code snippet shows how to utilize the TestServer's internal pubsub to be able to test with it outside of the volttron platform.
def test_send_alert():
""" Test that an agent can send an alert through the pubsub message bus."""
# Create an agent to run the test with
agent = Agent(identity='test-health')
# Create the server and connect the agent with the server
ts = TestServer()
ts.connect_agent(agent=agent)
# The health.send_alert should send a pubsub message through the message bus
agent.vip.health.send_alert("my_alert", Status.build(STATUS_BAD, "no context"))
# We know that there should only be a single message sent through the bus and
# the specifications of the message to test against.
messages = ts.get_published_messages()
assert len(messages) == 1
headers = messages[0].headers
message = json.loads(messages[0].message)
assert headers['alert_key'] == 'my_alert'
assert message['context'] == 'no context'
assert message['status'] == 'BAD'
Reference the volttrontesting package from within your environment in order to build tests against the TestServer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
volttron-testing-0.3.1a26.tar.gz
(38.7 kB
view details)
Built Distribution
File details
Details for the file volttron-testing-0.3.1a26.tar.gz
.
File metadata
- Download URL: volttron-testing-0.3.1a26.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b2 CPython/3.8.14 Linux/5.15.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e9780b7212ae53e7a86926f6810db3d14f1d85c3a6c79d7b77286c3b800970f |
|
MD5 | 94bc6f167de08d20e052829e0b519154 |
|
BLAKE2b-256 | 32173b7cb0e521c55d7542b933590fc5d827ec37b66be318305ba3f5cc17d9ae |
File details
Details for the file volttron_testing-0.3.1a26-py3-none-any.whl
.
File metadata
- Download URL: volttron_testing-0.3.1a26-py3-none-any.whl
- Upload date:
- Size: 45.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b2 CPython/3.8.14 Linux/5.15.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7aed7c2555151f6c5a745f4e2dfcd6ddd26b66ef9ecf2c1954550e4a38516a52 |
|
MD5 | 2356029f5e5165d9d80cc4efe5b48206 |
|
BLAKE2b-256 | 40ccfca794089d8642f06bb202a21db327a39d99168a0d58845a26d542c8a258 |