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.1a17.tar.gz
(37.8 kB
view details)
Built Distribution
File details
Details for the file volttron-testing-0.3.1a17.tar.gz
.
File metadata
- Download URL: volttron-testing-0.3.1a17.tar.gz
- Upload date:
- Size: 37.8 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 | 560ecce8f7c94d15e428798fccc2d42a99ad157b0591f03d850f2b2c974a771d |
|
MD5 | 5aeb43fe53d654baa83a9dec260be13a |
|
BLAKE2b-256 | 67b306bea336560ae47f859a36f2475bfa9eee8eb8b35da4aa7c672502a67ad8 |
File details
Details for the file volttron_testing-0.3.1a17-py3-none-any.whl
.
File metadata
- Download URL: volttron_testing-0.3.1a17-py3-none-any.whl
- Upload date:
- Size: 40.7 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 | a30ba4785214a3a4454ad17c2c29e825db494e708063c38171d324cd444e71ba |
|
MD5 | d190ea1e0cab304fef8e198ac8cc1aa8 |
|
BLAKE2b-256 | 86342858080c4bb347ac8d3a02fc3d1b24bac9d2fdb27fad71edd6f36f93b4c7 |