I’m building an assistant that will rely heavily on functions inside my action server. So far, I have four custom actions. Ideally, I’d like to ensure that these custom actions always behave the way I intend for them to behave, especially as I start to develop the assistant further.
I wrote a list of things I’d like to assert and wrote a mock domain and tracker. So far, the tests only assert that the action names are correct, as shown below:
I don’t quite know how to execute the run function of each of these classes and assert that the returned events and response that will be sent to the user (through dispatcher.utter_message) are correct.
I tried passing my mock tracker and domain into the function to assert that my events list will return empty , but the code raises a TypeError when it reaches the line which calls the dispatcher as shown below:
File "/app/actions/actions.py", line 48, in run
text=f"Hello world!")
TypeError: utter_message() missing 1 required positional argument: 'self'
It’s obvious that I’m doing something wrong here. What is the best way to test custom actions on the action server without running into these kind of errors with the SDK?
@marcos.allysson
Thanks for the reply, but I think you missed the point. Could be my fault since I may not have been super clear. My actions work, I have a functional assistant. I just have lots of logic going on inside class ActionHelloWorld(Action) such as communicating with my database and fetching things, and it returns different responses based on what response it gets back from the post request.
What I am trying to do here is not testing the conversation logic of Rasa (since I already did that and all tests run successfully), but to create unit tests for my action server to ensure that all functions in my endpoint behave as needed even with corner cases.
We are working on adding some custom action unit test examples into the financial demo bot. It’s a work in progress but you’ll find it in the db branch. Here are the files to look at: