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.1a22.tar.gz
(38.1 kB
view details)
Built Distribution
File details
Details for the file volttron-testing-0.3.1a22.tar.gz
.
File metadata
- Download URL: volttron-testing-0.3.1a22.tar.gz
- Upload date:
- Size: 38.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b2 CPython/3.8.14 Linux/5.15.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fda0a246b5192e8ba41fbb5f83ea35aebabee32b504204a428fcd2898acc49f0 |
|
MD5 | c5f29f7d23699f83ce634538eaff828b |
|
BLAKE2b-256 | 41930949e22a81879f0c4b63b60fdfb8fee7238ce0960f59dc4c219f871e9a02 |
File details
Details for the file volttron_testing-0.3.1a22-py3-none-any.whl
.
File metadata
- Download URL: volttron_testing-0.3.1a22-py3-none-any.whl
- Upload date:
- Size: 41.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b2 CPython/3.8.14 Linux/5.15.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1786f8e90f8d0b98733d33c2f95754577c79546ec54a06e6571a9952e07aa8a0 |
|
MD5 | 85806b4ac2aca2633658dfd497a5c189 |
|
BLAKE2b-256 | e4bf1cc34bb816d1d2f18be4d8b796aff386da0b97c38f50c01d4c6f749bdcd7 |