Carla Test Helper v0.1.3 CarlaTestHelper View Source

Carla test helper

Link to this section Summary

Functions

Similar to quick_reply/4 but instead of quick replies, this scans text and gallery card item buttons for a button with the label label

Similar to quick_reply/4 but instead of quick replies, this scans text and gallery card item buttons for a button with the label label

Similar to quick_reply/4 but instead of quick replies, this scans text and gallery card item buttons for a button with the label label

Macro to help easily define a set a list of assertions to test against the bot. carlatest will accept a name and a list of assertion functions and return a new function with the given name that accepts 2 parameters

Prints the last response from a request

Sends message for the given uuid and asserts the response is the expected_action

Scans the buttons portion of the given response for the first quick reply button with the label label and sends its payload as the given user for uuid. Then asserts that the resulting response is expected_action

Link to this section Functions

Link to this function button_action(response, uuid, label, expected_action) View Source
button_action(map(), String.t(), String.t(), String.t()) :: map()

Similar to quick_reply/4 but instead of quick replies, this scans text and gallery card item buttons for a button with the label label.

Parameters:

  • response - Response to look for a button with label
  • uuid - The user uuid to send the message as
  • label - The label of the button you want to “click”
  • expected_action - The resulting response’s action

Returns the response after clicking the button.

Link to this function button_linkout(response, uuid, label, value) View Source
button_linkout(map(), String.t(), String.t(), String.t()) :: map()

Similar to quick_reply/4 but instead of quick replies, this scans text and gallery card item buttons for a button with the label label.

Parameters:

  • response - Response to look for a button with label
  • uuid - The user uuid to send the message as
  • label - The label of the button you want to “click”
  • value - The linkout button payload value

Returns the response after clicking the button.

Link to this function button_linkout(response, uuid, label, value, params) View Source
button_linkout(map(), String.t(), String.t(), String.t(), [String.t()]) :: map()

Similar to quick_reply/4 but instead of quick replies, this scans text and gallery card item buttons for a button with the label label.

Parameters:

  • response - Response to look for a button with label
  • uuid - The user uuid to send the message as
  • label - The label of the button you want to “click”
  • value - The linkout button payload value
  • params - The params expected in the value

Returns the response after clicking the button.

Link to this macro carlatest(name, list) View Source (macro)

Macro to help easily define a set a list of assertions to test against the bot. carlatest will accept a name and a list of assertion functions and return a new function with the given name that accepts 2 parameters.

The resulting function’s parameters:

  • uuid - The uuid of the user to use when testing the list of assertions.
  • state (defaults to %{}) - The state to setup for the user before running tests.

The macro’s assertions argument is a expected to be a list of assertion functions. This macro will take the list of functions and iterate through each one and call them. This allows the user of the macro to define a conversation test case like so:

carlatest "request details optima", do: [
  message("optima", "request.details.optima"),
  quick_reply("Build & Price", "build:_optima"),
]
Link to this function debug_last_response(response, uuid) View Source
debug_last_response(map(), String.t()) :: map()

Prints the last response from a request.

Parameters:

  • response - Response to print
  • uuid - Unused, The user uuid passed down
Link to this function message(response, uuid, message, expected_action) View Source
message(map(), String.t(), String.t(), String.t()) :: map()

Sends message for the given uuid and asserts the response is the expected_action.

Parameters:

  • _response - Unused, just made it 4 args to be in line w/ quick_reply and button
  • uuid - The user to send the message as
  • message - The message to send
  • expected_action - The action to assert when it comes back

Returns a Response object.

Link to this function quick_reply(response, uuid, label, expected_action) View Source
quick_reply(map(), String.t(), String.t(), String.t()) :: map()

Scans the buttons portion of the given response for the first quick reply button with the label label and sends its payload as the given user for uuid. Then asserts that the resulting response is expected_action.

Parameters:

  • response - Response to look for a button with label
  • uuid - The user uuid to send the message as
  • label - The label of the button you want to “click”
  • expected_action - The resulting response’s action

Returns the response after clicking the quick_reply.