def setUp(self): super(LowConfidenceAdapterTestCase, self).setUp() self.adapter = LowConfidenceAdapter() # Add a mock storage adapter to the context self.adapter.set_context(MockContext()) possible_choices = [ Statement( 'Who do you love?', in_response_to=[Response('I hear you are going on a quest?')]), Statement('What is the meaning of life?', in_response_to=[ Response('Yuck, black licorice jelly beans.') ]), Statement('I am Iron Man.', in_response_to=[Response('What... is your quest?')]), Statement('What... is your quest?', in_response_to=[Response('I am Iron Man.')]), Statement( 'Yuck, black licorice jelly beans.', in_response_to=[Response('What is the meaning of life?')]), Statement('I hear you are going on a quest?', in_response_to=[Response('Who do you love?')]), ] self.adapter.context.storage.filter = MagicMock( return_value=possible_choices)
class LowConfidenceAdapterTestCase(TestCase): """ Test cases for the LowConfidenceAdapter """ def setUp(self): super(LowConfidenceAdapterTestCase, self).setUp() self.adapter = LowConfidenceAdapter() # Add a mock storage adapter to the context self.adapter.set_context(MockContext()) possible_choices = [ Statement( 'Who do you love?', in_response_to=[Response('I hear you are going on a quest?')]), Statement('What is the meaning of life?', in_response_to=[ Response('Yuck, black licorice jelly beans.') ]), Statement('I am Iron Man.', in_response_to=[Response('What... is your quest?')]), Statement('What... is your quest?', in_response_to=[Response('I am Iron Man.')]), Statement( 'Yuck, black licorice jelly beans.', in_response_to=[Response('What is the meaning of life?')]), Statement('I hear you are going on a quest?', in_response_to=[Response('Who do you love?')]), ] self.adapter.context.storage.filter = MagicMock( return_value=possible_choices) def test_high_confidence(self): """ Test the case that a high confidence response is known. """ statement = Statement('What is your quest?') confidence, match = self.adapter.process(statement) self.assertEqual(confidence, 0) self.assertEqual(match, self.adapter.default_response) def test_low_confidence(self): """ Test the case that a high confidence response is not known. """ statement = Statement('Is this a tomato?') confidence, match = self.adapter.process(statement) self.assertEqual(confidence, 1) self.assertEqual(match, self.adapter.default_response)
class LowConfidenceAdapterTestCase(TestCase): """ Test cases for the LowConfidenceAdapter """ def setUp(self): super(LowConfidenceAdapterTestCase, self).setUp() self.adapter = LowConfidenceAdapter() # Add a mock storage adapter to the context self.adapter.set_context(MockContext()) possible_choices = [ Statement("Who do you love?", in_response_to=[Response("I hear you are going on a quest?")]), Statement("What is the meaning of life?", in_response_to=[Response("Yuck, black licorice jelly beans.")]), Statement("I am Iron Man.", in_response_to=[Response("What... is your quest?")]), Statement("What... is your quest?", in_response_to=[Response("I am Iron Man.")]), Statement("Yuck, black licorice jelly beans.", in_response_to=[Response("What is the meaning of life?")]), Statement("I hear you are going on a quest?", in_response_to=[Response("Who do you love?")]), ] self.adapter.context.storage.filter = MagicMock(return_value=possible_choices) def test_high_confidence(self): """ Test the case that a high confidence response is known. """ statement = Statement("What is your quest?") confidence, match = self.adapter.process(statement) self.assertEqual(confidence, 0) self.assertEqual(match, self.adapter.default_response) def test_low_confidence(self): """ Test the case that a high confidence response is not known. """ statement = Statement("Is this a tomato?") confidence, match = self.adapter.process(statement) self.assertEqual(confidence, 1) self.assertEqual(match, self.adapter.default_response)
def setUp(self): super(LowConfidenceAdapterTestCase, self).setUp() self.adapter = LowConfidenceAdapter() # Add a mock storage adapter to the context self.adapter.set_context(MockContext()) possible_choices = [ Statement("Who do you love?", in_response_to=[Response("I hear you are going on a quest?")]), Statement("What is the meaning of life?", in_response_to=[Response("Yuck, black licorice jelly beans.")]), Statement("I am Iron Man.", in_response_to=[Response("What... is your quest?")]), Statement("What... is your quest?", in_response_to=[Response("I am Iron Man.")]), Statement("Yuck, black licorice jelly beans.", in_response_to=[Response("What is the meaning of life?")]), Statement("I hear you are going on a quest?", in_response_to=[Response("Who do you love?")]), ] self.adapter.context.storage.filter = MagicMock(return_value=possible_choices)