Skip to main content

The volttron-testing library contains classes and utilities for interacting with a VOLTTRON instance.

Project description

volttron-testing

Eclipse VOLTTRON™ Python 3.10 Python 3.11 Run Pytests pypi version

The volttron-testing library contains classes and utilities for interacting with a VOLTTRON instance.

Prerequisites

  • Python >= 3.10

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.

Development

Please see the following for contributing guidelines contributing.

Please see the following helpful guide about developing modular VOLTTRON agents

Disclaimer Notice

This material was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of their employees, nor any jurisdiction or organization that has cooperated in the development of these materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents that its use would not infringe privately owned rights.

Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.

Project details


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.5.0rc1.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

volttron_testing-0.5.0rc1-py3-none-any.whl (51.1 kB view details)

Uploaded Python 3

File details

Details for the file volttron_testing-0.5.0rc1.tar.gz.

File metadata

  • Download URL: volttron_testing-0.5.0rc1.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for volttron_testing-0.5.0rc1.tar.gz
Algorithm Hash digest
SHA256 1afb9c69115d97c4f3bfabd21ebaaccf4d6fdfcde8dc08373bbe6ff9b49c3c32
MD5 6e2221c4d6d0ae762719fcc069988c36
BLAKE2b-256 23c68cdb3d6ad1d22cb8b99c9118c4780d6ae801845ecc857a006b792a575872

See more details on using hashes here.

File details

Details for the file volttron_testing-0.5.0rc1-py3-none-any.whl.

File metadata

  • Download URL: volttron_testing-0.5.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 51.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for volttron_testing-0.5.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c32ea174cc7f349736a04445dd73b6bad7ef4a841980ae5c41228553c61e2f1
MD5 740e0f1ca9107c4d32351075589e414e
BLAKE2b-256 3c0b385f080b7e69dfa0026e183615d60e64e3bff774d0d78582e0ef4cd01560

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page