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.1a24.tar.gz
(38.1 kB
view details)
Built Distribution
File details
Details for the file volttron-testing-0.3.1a24.tar.gz
.
File metadata
- Download URL: volttron-testing-0.3.1a24.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 | a7544c6b82c6aa7bc375bb5ac167fc3bab77e6bcea630fab85f20bee5d1198ba |
|
MD5 | 7a1fbb0a9136d3fae2e788a5c5115b03 |
|
BLAKE2b-256 | 336d52a6ddb4cd0d9e76949d310b7d74a42edac93ee48a6d868ca7292cce0529 |
File details
Details for the file volttron_testing-0.3.1a24-py3-none-any.whl
.
File metadata
- Download URL: volttron_testing-0.3.1a24-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 | 3cb4780c84b9b761215505ae630ab24e9662b0b0245877d94723ba440a68f36b |
|
MD5 | 04c784d866903e783002ceab8f876e07 |
|
BLAKE2b-256 | 325d2d4990316e211b1e18000c57790e7893d218c60e2339c7e19adde5821213 |