def test_0(): conv_client = mock.Mock() conv_client.message.return_value = { 'context': { 'send_no_input': 'no' }, 'output': { 'text': 'fake output text' }, } slack_client = mock.Mock() cloudant_store = mock.Mock() wosbot = watson_online_store.WatsonOnlineStore('botid', slack_client, conv_client, cloudant_store) wosbot.handle_message("this is a test", "this is a channel") conv_client.assert_has_calls([ mock.call.message(context={ 'send_no_input': 'no', 'email': None, 'logged_in': False }, message_input={'text': 'this is a test'}, workspace_id=mock.ANY) ]) slack_client.assert_has_calls([ mock.call.api_call( 'chat.postMessage', as_user=True, channel='this is a channel', text='f\na\nk\ne\n \no\nu\nt\np\nu\nt\n \nt\ne\nx\nt\n') ])
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.get_environments.return_value = { 'environments': [{'environment_id': self.fake_environment_id, '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)
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.wosbot = watson_online_store.WatsonOnlineStore( 'UBOTID', self.slack_client, self.conv_client, self.discovery_client, self.cloudant_store)
def setUp(self): mock.Mock(watson_online_store.os.environ, return_value={}) self.slack_client = mock.Mock() self.conv_client = mock.MagicMock() self.watson_online_store = 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.watson_online_store.context_merge = message_json.message 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')