Esempio n. 1
0
    def test_0(self):

        fake_channel = "fake channel"
        sender = watson_online_store.SlackSender(self.slack_client,
                                                 fake_channel)
        fake_response = "this is a fake response"

        self.conv_client.message.return_value = {
            'context': {
                'send_no_input': 'no'
            },
            'output': {
                'text': [fake_response]
            },
        }

        self.wos.handle_message("this is a test", sender)

        self.conv_client.assert_has_calls([
            mock.call.message(context={},
                              input={'text': 'this is a test'},
                              workspace_id=mock.ANY)
        ])
        self.slack_client.api_call.assert_has_calls([
            mock.call('chat.postMessage',
                      as_user=True,
                      channel=fake_channel,
                      text=fake_response + '\n')
        ])
Esempio n. 2
0
    def setUp(self):
        mock.Mock(watson_online_store.os.environ, return_value={})
        self.slack_client = mock.Mock()
        self.conv_client = mock.Mock()
        self.fake_workspace_id = 'fake workspace id'
        self.conv_client.list_workspaces.return_value = {
            'workspaces': [{'workspace_id': self.fake_workspace_id,
                            'name': 'watson-online-store'}]}
        self.cloudant_store = mock.Mock()
        self.discovery_client = mock.Mock()
        self.fake_data_source = 'IBM_STORE'
        self.fake_environment_id = 'fake env id'
        self.fake_collection_id = "fake collection id"
        self.discovery_client.get_environment.return_value = {
            'environment_id': self.fake_environment_id}
        self.discovery_client.list_environments.return_value = {
            'environments': [{'environment_id': self.fake_environment_id,
                              'read_only': False,
                              'name': 'ibm-logo-store'}]}
        self.discovery_client.get_collection.return_value = {
            'collection_id': self.fake_collection_id}
        self.discovery_client.list_collections.return_value = {
            'collections': [{'collection_id': self.fake_collection_id,
                             'name': 'ibm-logo-store'}]}

        self.wos = watson_online_store.WatsonOnlineStore(
            'UBOTID',
            self.slack_client,
            self.conv_client,
            self.discovery_client,
            self.cloudant_store)

        self.sender = watson_online_store.SlackSender(
            self.slack_client, 'sender-channel')