Skip to main content

None

Project description

volttron-testing

Run Pytests pypi version

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


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.1a23.tar.gz (38.1 kB view details)

Uploaded Source

Built Distribution

volttron_testing-0.3.1a23-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file volttron-testing-0.3.1a23.tar.gz.

File metadata

  • Download URL: volttron-testing-0.3.1a23.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

Hashes for volttron-testing-0.3.1a23.tar.gz
Algorithm Hash digest
SHA256 d9d543b793bf5cca2a08f52a7d41b8fc6cf834e4bf965b061f6e12df198f80d3
MD5 c4654eadc744e956a5ee16482318236c
BLAKE2b-256 36959b942fa23382a8feca236f5fca78a2f6f931bca3908ef566f761fc87ce30

See more details on using hashes here.

File details

Details for the file volttron_testing-0.3.1a23-py3-none-any.whl.

File metadata

File hashes

Hashes for volttron_testing-0.3.1a23-py3-none-any.whl
Algorithm Hash digest
SHA256 4208396c619005a32e5d66fb6069b7207ff142e6f6289dd8943b2183e4a76241
MD5 3dd34749a995d4496332e31ae9e280e5
BLAKE2b-256 9901660903619a7caada001426d6e9635700a68dcbe811f395bb0254cbca5f8a

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