Testing Rasa stories

Hi

This is my story:

- story: Accept data privacy and customer concern
  steps:
    - intent: affirm
      entities:
      - data_privacy_declaration: "Alright"
    - action: utter_customer_concern

I want to test the story with rasa test. But first I have written the test-story in tests/test_stories.yml:

- story: test accept data privacy and customer concern
  steps:
    - user: |
        Alright
      intent: affirm
    - slot_was_set:
        - requested_slot: data_privacy_declaration
        - data_privacy_declaration: "Alright" 
    - action: utter_customer_concern

Unfortunately, the test failed as shown in failed_test_stories.yml:

  steps:
  - intent: affirm
  - slot_was_set:
    - requested_slot: data_privacy_declaration
  - slot_was_set:
    - data_privacy_declaration: Alright
  - action: utter_customer_concern  # predicted: action_reset_slot

Any idea why the test is failing?

If I run the bot, everything works perfectly.

@Chatbot_Ra Is action_reset_slot a custom action that you implemented? When is this used, in other stories or rules? And to double-check you’re using slot auto-fill to set the data_privacy_declaration slot?

I would suggest adding a slot_was_set step in your stories.yml, after intent: affirm.

1 Like

No, it’s not. It comes from Rasa.

I gues the problem is the way the story gets triggered. Please take a closer look at the story:

- story: Accept data privacy and customer concern
  steps:
    - intent: affirm
      entities:
      - data_privacy_declaration: "Alright"
    - action: utter_customer_concern

It’s triggered with an intent affirm and an entity data_privacy_declaration. The question which triggers this story is defined in domain file as following:

  utter_accept_privacy_rules:
  - text: Are you fine with data privacy rules?
    buttons:
    - payload: /affirm{{"data_privacy_declaration":"Alright"}}
      title: Yes
    - payload: /denny{{"data_privacy_declaration":"Nope"}}
      title: No

I specified data_privacy_declaration as slot and entity in the domain file.

I have the feeling that the way I write the test is not correct.

@anca Thank you very much: Your propossed solution was successful :slight_smile:

1 Like