예제 #1
0
 def test_reply(self):
     state = createNewState()
     # get reply from new state
     reply = getReply(state)
     self.assertEqual(reply, "")
     # set reply and re-fetch it
     setReply(state, "hi")
     reply = getReply(state)
     self.assertEqual(reply, "hi")
예제 #2
0
 def test_intent(self):
     state = createNewState()
     # get intent from new state
     intent = getIntent(state)
     self.assertEqual(intent, "")
     # set intent and re-fetch it
     setIntent(state, "food.order")
     intent = getIntent(state)
     self.assertEqual(intent, "food.order")
예제 #3
0
 def test_message(self):
     state = createNewState()
     # get message from new state
     message = getMessage(state)
     self.assertEqual(message, "")
     # set message and re-fetch it
     setMessage(state, "hi")
     message = getMessage(state)
     self.assertEqual(message, "hi")
예제 #4
0
 def test_context(self):
     state = createNewState()
     # get context from new state
     context = getContext(state, "location")
     self.assertEqual(context, None)
     # set context and re-fetch it
     setContext(state, "location", "Malang")
     context = getContext(state, "location")
     self.assertEqual(context, "Malang")
     # set context with subkey and re-fetch it
     setContext(state, "food.name", "pudding")
     setContext(state, "food.quantity", 5)
     context = getContext(state, "food")
     self.assertDictEqual(context, {"name": "pudding", "quantity": 5})
예제 #5
0
 def test_create_new_state(self):
     expected = {"intent": None, "context": {}, "message": "", "reply": ""}
     state = createNewState()
     self.assertDictEqual(state, expected)