class DriverSpecs

Overview

A place driver has 4 typical points of IO contact

  1. Place driver protocol (placeos-core's point of contact)
  2. The modules transport layer (module to device comms)
  3. An optional HTTP client
  4. Redis for state storage and subscriptions

Defined in:

placeos-driver/driver-specs/mock_driver.cr
placeos-driver/driver-specs/mock_http.cr
placeos-driver/driver-specs/responder.cr
placeos-driver/driver-specs/runner.cr
placeos-driver/driver-specs/status_helper.cr

Constant Summary

DRIVER_ID = "spec_runner"
SYSTEM_ID = "spec_runner_system"

Class Method Summary

Instance Method Summary

Class Method Detail

def self.mock_driver(driver_name : String, driver_exec = ENV["SPEC_RUN_DRIVER"], &) #

[View source]

Instance Method Detail

def exec(function, *args, user_id = nil) #

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"


[View source]
def exec(function, user_id = nil, **args) #

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"


[View source]
def exec(function, *args, user_id = nil, &) #

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"


[View source]
def exec(function, user_id = nil, **args, &) #

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"


[View source]
def expect_http_request(timeout = 1.seconds, &) #

provides a method for accepting and responding to HTTP requests being made by the driver

for an example of how this works see an existing driver


[View source]
def expect_reconnect(timeout = 5.seconds) : TCPSocket #

A particular response might disconnect the socket Then we want to wait for the reconnect to occur before continuing the spec


[View source]
def expect_send(timeout = 500.milliseconds) : Bytes #

obtain some data you were expecting to receive from the driver. Typically triggered by an exec you've made.

expect_send.should eq "some data"


[View source]
def publish(channel, message) #

publish an event for the driver to process


[View source]
def responds(data) #

transmits some data to the driver, typically a response to something the driver has sent

transmit "\nsome response"


[View source]
def settings(new_settings) #

allows you to provide alternative settings to the driver being tested.

by default the drivers default_settings are used


[View source]
def should_send(data, timeout = 500.milliseconds) #

expects the data provided to be sent

should_send "some data"


[View source]

provides access to the drivers status state.

status[:volume].should eq(50)


[View source]
def system(module_id : String | Symbol) #

Grab a Mock driver instance that has been defined by updating the system

For example a system may look like: {Display: {MockDisplay, MockDisplay}}

We can obtain mock display 2 by calling mock_display = system(:Display_2)

Then we can check status on it mock_display[:power]?.should eq true


[View source]
def system(details) #

provides a new system definition for testing Logic Modules

expects {ModuleName: {Klass, Klass}}

see an example of it in use


[View source]
def transmit(data, pause = 100.milliseconds) #

transmits some data to the driver, typically a response to something the driver has sent

transmit "\nsome response"


[View source]