forked from aichaos/rivescript-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_botvars.py
More file actions
66 lines (49 loc) · 2 KB
/
Copy pathtest_botvars.py
File metadata and controls
66 lines (49 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from .config import RiveScriptTestCase
class BotvarTests(RiveScriptTestCase):
"""Test bot variables."""
def test_bot_variables(self):
self.new("""
! var name = Aiden
! var age = 5
+ what is your name
- My name is <bot name>.
+ how old are you
- I am <bot age>.
+ what are you
- I'm <bot gender>.
+ happy birthday
- <bot age=6>Thanks!
+ who is your master
- My master is <bot master>.
""")
self.rs.set_variable("master", "kirsle")
self.reply("What is your name?", "My name is Aiden.")
self.reply("How old are you?", "I am 5.")
self.reply("What are you?", "I'm undefined.")
self.reply("Happy birthday!", "Thanks!")
self.reply("How old are you?", "I am 6.")
self.reply("Who is your master?", "My master is kirsle.")
self.assertEqual(self.rs.get_variable("age"), "6")
self.assertEqual(self.rs.get_variable("master"), "kirsle")
self.assertEqual(self.rs.get_variable("fake"), "undefined")
def test_global_variables(self):
self.new("""
! global debug = false
+ debug mode
- Debug mode is: <env debug>
+ set debug mode *
- <env debug=<star>>Switched to <star>.
+ are you testing
- Testing: <env testing>
""")
self.rs.set_global("testing", "true")
self.reply("Debug mode.", "Debug mode is: false")
self.reply("Set debug mode true", "Switched to true.")
self.reply("Debug mode?", "Debug mode is: true")
self.reply("Are you testing?", "Testing: true")
self.assertEqual(self.rs.get_global("debug"), "true")
self.assertEqual(self.rs.get_global("testing"), "true")
self.assertEqual(self.rs.get_global("fake"), "undefined")