How to use list_workspaces method in tempest

Best Python code snippet using tempest_python

test_watson_style_me.py

Source:test_watson_style_me.py Github

copy

Full Screen

1import unittest2import ddt3import mock4from StyleMe.watsonstyleme.tests.unit import message as message_json5from StyleMe.watsonstyleme import watson_style_me6@ddt.ddt7class WOSTestCase(unittest.TestCase):8 def setUp(self):9 mock.Mock(watson_style_me.os.environ, return_value={})10 self.slack_client = mock.Mock()11 self.assistant_client = mock.MagicMock()12 self.watson_style_me = mock.Mock()13 self.fake_workspace_id = 'fake workspace id'14 self.assistant_client.list_workspaces.return_value.\15 get_result.return_value = {16 'workspaces': [{'workspace_id': self.fake_workspace_id,17 'name': 'watson-online-store'}]}18 self.cloudant_store = mock.Mock()19 self.discovery_client = mock.MagicMock()20 self.fake_data_source = 'IBM_STORE'21 self.fake_environment_id = 'fake env id'22 self.fake_collection_id = "fake collection id"23 self.discovery_client.get_environment.return_value.\24 get_result.return_value = {25 'environment_id': self.fake_environment_id}26 self.discovery_client.list_environments.return_value.\27 get_result.return_value = {28 'environments': [{'environment_id': self.fake_environment_id,29 'read_only': False,30 'name': 'ibm-logo-store'}]}31 self.discovery_client.get_collection.get_result.return_value = {32 'collection_id': self.fake_collection_id}33 self.discovery_client.list_collections.return_value.\34 get_result.return_value = {35 'collections': [{'collection_id': self.fake_collection_id,36 'name': 'ibm-logo-store'}]}37 self.watson_style_me.context_merge = message_json.message38 self.wos = watson_style_me.WatsonStyleMe(39 'UBOTID',40 self.slack_client,41 self.assistant_client,42 self.discovery_client,43 self.cloudant_store)44 self.sender = watson_style_me.SlackSender(45 self.slack_client, 'sender-channel')46 def test_0(self):47 fake_channel = "fake channel"48 sender = watson_style_me.SlackSender(49 self.slack_client, fake_channel)50 fake_response = "this is a fake response"51 self.assistant_client.message.return_value.get_result.return_value = {52 'context': {'send_no_input': 'no'},53 'output': {'text': [fake_response]},54 }55 self.wos.handle_message("this is a test", sender)56 self.assistant_client.assert_has_calls([57 mock.call.message(context={},58 input={'text': 'this is a test'},59 workspace_id=mock.ANY)60 ])61 self.slack_client.api_call.assert_has_calls([62 mock.call(63 'chat.postMessage',64 as_user=True,65 channel=fake_channel,66 text=fake_response + '\n')67 ])68 @ddt.data(None, "", False)69 def test_init_customer_no_user_id(self, no_user_id):70 self.assertRaises(71 AssertionError, self.wos.init_customer, 'ignore', no_user_id)72 def test_init_customer_slack_fail(self):73 self.slack_client.api_call = mock.Mock(side_effect=Exception("Boom"))74 user = "testuser"75 self.wos.init_customer(self.sender, user)76 self.slack_client.api_call.assert_called_once_with(77 'users.info', user=user)78 @ddt.data(None, "", False, {},79 {'ok': False, 'error': 'yes'},80 {'user': {'profile': {'no-email': 'e@mail'}}},81 {'user': {'profile': {'email': None}}},82 {'user': {'profile': {'email': ''}}}83 )84 def test_init_customer_slack_unusable(self, ret):85 self.slack_client.api_call = mock.Mock(return_value=ret)86 user = "testuser"87 self.wos.init_customer(self.sender, user)88 self.slack_client.api_call.assert_called_once_with(89 'users.info', user=user)90 def test_init_customer_slack_user_old(self):91 test_email_addr = 'e@mail'92 self.slack_client.api_call = mock.Mock(return_value={93 'user': {'profile': {'email': test_email_addr}}})94 self.cloudant_store.find_customer = mock.Mock(return_value={95 'email': 'test-email',96 'first_name': 'test-first-name',97 'last_name': 'test-last-name',98 })99 user = "testuser"100 self.wos.init_customer(self.sender, user)101 self.slack_client.api_call.assert_called_once_with(102 'users.info', user=user)103 self.cloudant_store.find_customer.assert_called_once_with(104 test_email_addr)105 def test_init_customer_slack_new(self):106 test_email_addr = 'e@mail'107 self.slack_client.api_call = mock.Mock(108 return_value={'user': {'profile': {'email': test_email_addr,109 'first_name': 'first-name',110 'last_name': 'last-name',111 }}})112 self.cloudant_store.find_customer = mock.Mock(return_value={})113 user = "testuser"114 self.wos.init_customer(self.sender, user)115 self.slack_client.api_call.assert_called_once_with(116 'users.info', user=user)117 self.cloudant_store.find_customer.assert_called_once_with(118 test_email_addr)119 def test_init_customer_slack_no_name(self):120 test_email_addr = 'e@mail'121 self.slack_client.api_call = mock.Mock(122 return_value={'user': {'profile': {'email': test_email_addr,123 'first_name': '',124 'last_name': '',125 }}})126 self.cloudant_store.find_customer = mock.Mock(return_value={})127 user = "testuser"128 self.wos.init_customer(self.sender, user)129 self.slack_client.api_call.assert_called_once_with(130 'users.info', user=user)131 self.cloudant_store.find_customer.assert_called_once_with(132 test_email_addr)133 @ddt.data(134 ([{'text': '<@UBOTID> suFFix', 'channel': 'C', 'user': 'U'}],135 ('suffix', 'C', 'U')),136 ([{'text': 'prefix <@UBOTID> Suffix', 'channel': 'C', 'user': 'U'}],137 ('prefix suffix', 'C', 'U')),138 ([{'text': 'prefix <@UBOTID> Suffix<@UBOTID>Tail',139 'channel': 'C', 'user': 'U'}],140 ('prefix suffixtail', 'C', 'U')),141 ([{'text': 'prefix <@UBOTID> suffix', 'channel': 'DXXX', 'user': 'U'}],142 ('prefix suffix', 'DXXX', 'U')),143 ([{'text': 'this is a dm', 'channel': 'DXXX', 'user': 'U'}],144 ('this is a dm', 'DXXX', 'U')))145 @ddt.unpack146 def test_parse_slack_output(self, output_list, expected):147 actual = self.wos.parse_slack_output(output_list)148 self.assertEqual(expected, actual)149 @ddt.data([{}, # no text150 {'text': '<@UBOTID> hi', 'user_profile': 'x'}, # has profile151 {'text': 'hello world', 'channel': 'NOTDM'} # no at and not DM152 ])153 def test_parse_slack_output_to_skip(self, output_list):154 expected = (None, None, None)155 actual = self.wos.parse_slack_output(output_list)156 self.assertEqual(expected, actual)157 def test_setup_conversation_workspace_by_name_default(self):158 test_environ = {}159 expected_workspace_id = 'this is the one'160 self.assistant_client.list_workspaces = mock.MagicMock()161 self.assistant_client.list_workspaces.return_value.\162 get_result.return_value = {163 'workspaces': [{'workspace_id': 'other', 'name': 'foo'},164 {'workspace_id': expected_workspace_id,165 'name': 'watson-online-store'}]}166 wos = watson_style_me.WatsonStyleMe167 actual = wos.setup_assistant_workspace(self.assistant_client,168 test_environ)169 self.assistant_client.list_workspaces.assert_called_once()170 self.assertEqual(expected_workspace_id, actual)171 def test_setup_conversation_workspace_by_name_env(self):172 test_environ = {'WORKSPACE_NAME': 'foo name'}173 expected_workspace_id = 'this is the one'174 self.assistant_client.list_workspaces = mock.MagicMock()175 self.assistant_client.list_workspaces.return_value.\176 get_result.return_value = {177 'workspaces': [{'workspace_id': 'other', 'name': 'foo'},178 {'workspace_id': expected_workspace_id,179 'name': test_environ['WORKSPACE_NAME']}]}180 wos = watson_style_me.WatsonStyleMe181 actual = wos.setup_assistant_workspace(self.assistant_client,182 test_environ)183 self.assistant_client.list_workspaces.assert_called_once()184 self.assertEqual(expected_workspace_id, actual)185 def test_setup_conversation_workspace_by_id(self):186 expected_workspace_id = 'testing with a ws ID'187 test_environ = {'WORKSPACE_ID': expected_workspace_id}188 self.assistant_client.list_workspaces.return_value = mock.MagicMock()189 self.assistant_client.list_workspaces.return_value.\190 get_result.return_value = {191 'workspaces': [{'workspace_id': 'other'},192 {'workspace_id': expected_workspace_id,193 'name': 'foo'}]}194 wos = watson_style_me.WatsonStyleMe195 actual = wos.setup_assistant_workspace(196 self.assistant_client, test_environ)197 self.assistant_client.list_workspaces.return_value.\198 get_result.assert_called_once()199 self.assertEqual(expected_workspace_id, actual)200 def test_setup_conversation_workspace_by_id_not_found(self):201 expected_workspace_id = 'testing with a ws ID'202 test_environ = {'WORKSPACE_ID': expected_workspace_id}203 self.assistant_client.list_workspaces = mock.MagicMock()204 self.assistant_client.list_workspaces.return_value.\205 get_result.return_value = {206 'workspaces': [{'workspace_id': 'other'},207 {'workspace_id': 'wrong again'}]}208 wos = watson_style_me.WatsonStyleMe209 self.assertRaises(Exception,210 wos.setup_assistant_workspace,211 self.assistant_client,212 test_environ)213 self.assistant_client.list_workspaces.assert_called_once()214 def test_setup_conversation_workspace_create(self):215 expected_workspace_id = 'this was created'216 expected_workspace_name = 'and this was its name'217 test_environ = {'WORKSPACE_NAME': expected_workspace_name}218 self.assistant_client.list_workspaces = mock.MagicMock()219 self.assistant_client.list_workspaces.return_value.\220 get_result.return_value = {221 'workspaces': [{'workspace_id': 'other', 'name': 'any'}]}222 self.assistant_client.create_workspace = mock.MagicMock()223 self.assistant_client.create_workspace.return_value.\224 get_result.return_value = {225 'workspace_id': expected_workspace_id}226 wos = watson_style_me.WatsonStyleMe227 ws_json = {228 'counterexamples': 'c',229 'intents': 'i',230 'entities': 'e',231 'dialog_nodes': 'd',232 'metadata': 'm',233 'language': 'en',234 }235 wos.get_workspace_json = mock.Mock(return_value=ws_json)236 actual = wos.setup_assistant_workspace(237 self.assistant_client, test_environ)238 self.assistant_client.list_workspaces.assert_called_once()239 self.assistant_client.create_workspace.assert_called_once_with(240 expected_workspace_name,241 'Assistant workspace created by watson-online-store.',242 ws_json['language'],243 intents=ws_json['intents'],244 entities=ws_json['entities'],245 dialog_nodes=ws_json['dialog_nodes'],246 counterexamples=ws_json['counterexamples'],247 metadata=ws_json['metadata'])248 self.assertEqual(expected_workspace_id, actual)249 def test_setup_discovery_environment_by_id(self):250 expected_environment_id = 'testing with a env ID'251 expected_collection_id = 'testing with a coll ID'252 test_environ = {'DISCOVERY_ENVIRONMENT_ID': expected_environment_id,253 'DISCOVERY_COLLECTION_ID': expected_collection_id}254 self.discovery_client.get_environment = mock.Mock(return_value={255 'environment_id': expected_environment_id})256 self.discovery_client.get_collection = mock.Mock(return_value={257 'collection_id': expected_collection_id})258 wos = watson_style_me.WatsonStyleMe259 actual_env, actual_coll = (260 wos.setup_discovery_collection(self.discovery_client,261 self.fake_data_source,262 test_environ))263 self.discovery_client.get_environment.assert_called_once()264 self.discovery_client.get_collection.assert_called_once()265 self.assertEqual(expected_environment_id, actual_env)266 self.assertEqual(expected_collection_id, actual_coll)267 def test_setup_discovery_environment_by_name_default(self):268 test_environ = {}269 expected_environment_id = 'this is the env'270 expected_collection_id = 'this is the coll'271 self.discovery_client.list_environments = mock.MagicMock()272 self.discovery_client.list_environments.return_value.\273 get_result.return_value = {274 'environments': [{'environment_id': 'other',275 'name': 'foo',276 'read_only': False},277 {'environment_id': expected_environment_id,278 'read_only': False,279 'name': 'watson-online-store'}]}280 self.discovery_client.list_collections = mock.MagicMock()281 self.discovery_client.list_collections.return_value.\282 get_result.return_value = {283 'collections': [{'collection_id': 'other', 'name': 'foo'},284 {'collection_id': expected_collection_id,285 'name': 'ibm-logo-store'}]}286 wos = watson_style_me.WatsonStyleMe287 actual_env, actual_coll = (288 wos.setup_discovery_collection(self.discovery_client,289 self.fake_data_source,290 test_environ))291 self.discovery_client.list_environments.assert_called_once()292 self.discovery_client.list_collections.assert_called_once()293 self.assertEqual(expected_environment_id, actual_env)294 self.assertEqual(expected_collection_id, actual_coll)295 def test_format_ibm_store_output(self):296 ibm_product_name = "IBM Shirt"297 ibm_product_url = ("https://logostore-globalid.us/" +298 "ProductDetail.aspx?pid=240207")299 ibm_image_url = ("https://lf.staplespromotionalproducts.com/" +300 "lf?set=scale[50],env[live],output_format[png]," +301 "sku_number[200314539],sku_dir[200314]," +302 "view_code[D]%26call=url[file:san/com/sku.chain]")303 ibm_expected_response = [{304 'cart_number': "1",305 'name': ibm_product_name,306 'url': ibm_product_url,307 'image': ibm_image_url308 }, ]309 wos = watson_style_me.WatsonStyleMe310 # Test IBM Store formatting.311 # Note: use "XXX" to simulate that these tags are not at [0]312 ibm_results = [{313 'title': "IBM Shirt",314 'product_page': ("https://logostore-globalid.us/" +315 "ProductDetail.aspx?pid=240207"),316 'image_url': ("https://lf.staplespromotionalproducts.com/" +317 "lf?set=scale[50],env[live],output_format[png]," +318 "sku_number[200314539],sku_dir[200314]," +319 "view_code[D]%26call=url[file:san/com/sku.chain]")320 }, ]321 ibm_response = {'results': ibm_results}322 output = wos.format_discovery_response(ibm_response, "IBM_STORE")323 self.assertEqual(ibm_expected_response, output)324 def test_format_amazon_store_output(self):325 amz_product_name = "Amazon Shirt"326 amz_product_tag = '<a href='327 amz_product_url = 'http://www.test.xxx'328 amz_expected_response = [{329 'cart_number': "1",330 'name': amz_product_name,331 'url': amz_product_url,332 'image': amz_product_url333 }, ]334 wos = watson_style_me.WatsonStyleMe335 # Test Amazon Store formatting.336 # Note: use "XXX" to simulate that these tags are not at [0]337 amz_results = [{338 'extracted_metadata': {339 'title': amz_product_name340 },341 'html': "XXX" + amz_product_tag + " " + amz_product_url + ' >'342 }, ]343 amz_response = {'results': amz_results}344 output = wos.format_discovery_response(amz_response, "AMAZON")...

Full Screen

Full Screen

test_watson_online_store.py

Source:test_watson_online_store.py Github

copy

Full Screen

1import unittest2import ddt3import mock4from watsononlinestore import watson_online_store5@ddt.ddt6class WOSTestCase(unittest.TestCase):7 def setUp(self):8 mock.Mock(watson_online_store.os.environ, return_value={})9 self.slack_client = mock.Mock()10 self.conv_client = mock.Mock()11 self.fake_workspace_id = 'fake workspace id'12 self.conv_client.list_workspaces.return_value = {13 'workspaces': [{'workspace_id': self.fake_workspace_id,14 'name': 'watson-online-store'}]}15 self.cloudant_store = mock.Mock()16 self.discovery_client = mock.Mock()17 self.fake_data_source = 'IBM_STORE'18 self.fake_environment_id = 'fake env id'19 self.fake_collection_id = "fake collection id"20 self.discovery_client.get_environment.return_value = {21 'environment_id': self.fake_environment_id}22 self.discovery_client.get_environments.return_value = {23 'environments': [{'environment_id': self.fake_environment_id,24 'name': 'ibm-logo-store'}]}25 self.discovery_client.get_collection.return_value = {26 'collection_id': self.fake_collection_id}27 self.discovery_client.list_collections.return_value = {28 'collections': [{'collection_id': self.fake_collection_id,29 'name': 'ibm-logo-store'}]}30 self.wos = watson_online_store.WatsonOnlineStore(31 'UBOTID',32 self.slack_client,33 self.conv_client,34 self.discovery_client,35 self.cloudant_store)36 def test_0(self):37 fake_channel = "fake channel"38 sender = watson_online_store.SlackSender(39 self.slack_client, fake_channel)40 fake_response = "this is a fake response"41 self.conv_client.message.return_value = {42 'context': {'send_no_input': 'no'},43 'output': {'text': [fake_response]},44 }45 self.wos.handle_message("this is a test", sender)46 self.conv_client.assert_has_calls([47 mock.call.message(context={},48 message_input={'text': 'this is a test'},49 workspace_id=mock.ANY)50 ])51 self.slack_client.api_call.assert_has_calls([52 mock.call(53 'chat.postMessage',54 as_user=True,55 channel=fake_channel,56 text=fake_response + '\n')57 ])58 @ddt.data(None, "", False)59 def test_init_customer_no_user_id(self, no_user_id):60 self.assertRaises(61 AssertionError, self.wos.init_customer, no_user_id)62 def test_init_customer_slack_fail(self):63 self.slack_client.api_call = mock.Mock(side_effect=Exception("Boom"))64 user = "testuser"65 self.wos.init_customer(user)66 self.slack_client.api_call.assert_called_once_with(67 'users.info', user=user)68 @ddt.data(None, "", False, {},69 {'ok': False, 'error': 'yes'},70 {'user': {'profile': {'no-email': 'e@mail'}}},71 {'user': {'profile': {'email': None}}},72 {'user': {'profile': {'email': ''}}}73 )74 def test_init_customer_slack_unusable(self, ret):75 self.slack_client.api_call = mock.Mock(return_value=ret)76 user = "testuser"77 self.wos.init_customer(user)78 self.slack_client.api_call.assert_called_once_with(79 'users.info', user=user)80 def test_init_customer_slack_user_old(self):81 test_email_addr = 'e@mail'82 self.slack_client.api_call = mock.Mock(return_value={83 'user': {'profile': {'email': test_email_addr}}})84 self.cloudant_store.find_customer = mock.Mock(return_value={85 'email': 'test-email',86 'first_name': 'test-first-name',87 'last_name': 'test-last-name',88 })89 user = "testuser"90 self.wos.init_customer(user)91 self.slack_client.api_call.assert_called_once_with(92 'users.info', user=user)93 self.cloudant_store.find_customer.assert_called_once_with(94 test_email_addr)95 def test_init_customer_slack_new(self):96 test_email_addr = 'e@mail'97 self.slack_client.api_call = mock.Mock(98 return_value={'user': {'profile': {'email': test_email_addr,99 'first_name': 'first-name',100 'last_name': 'last-name',101 }}})102 self.cloudant_store.find_customer = mock.Mock(return_value={})103 user = "testuser"104 self.wos.init_customer(user)105 self.slack_client.api_call.assert_called_once_with(106 'users.info', user=user)107 self.cloudant_store.find_customer.assert_called_once_with(108 test_email_addr)109 @ddt.data(110 ([{'text': '<@UBOTID> suFFix', 'channel': 'C', 'user': 'U'}],111 ('suffix', 'C', 'U')),112 ([{'text': 'prefix <@UBOTID> Suffix', 'channel': 'C', 'user': 'U'}],113 ('prefix suffix', 'C', 'U')),114 ([{'text': 'prefix <@UBOTID> Suffix<@UBOTID>Tail',115 'channel': 'C', 'user': 'U'}],116 ('prefix suffixtail', 'C', 'U')),117 ([{'text': 'prefix <@UBOTID> suffix', 'channel': 'DXXX', 'user': 'U'}],118 ('prefix suffix', 'DXXX', 'U')),119 ([{'text': 'this is a dm', 'channel': 'DXXX', 'user': 'U'}],120 ('this is a dm', 'DXXX', 'U')))121 @ddt.unpack122 def test_parse_slack_output(self, output_list, expected):123 actual = self.wos.parse_slack_output(output_list)124 self.assertEqual(expected, actual)125 @ddt.data([{}, # no text126 {'text': '<@UBOTID> hi', 'user_profile': 'x'}, # has profile127 {'text': 'hello world', 'channel': 'NOTDM'} # no at and not DM128 ])129 def test_parse_slack_output_to_skip(self, output_list):130 expected = (None, None, None)131 actual = self.wos.parse_slack_output(output_list)132 self.assertEqual(expected, actual)133 def test_setup_conversation_workspace_by_name_default(self):134 test_environ = {}135 expected_workspace_id = 'this is the one'136 self.conv_client.list_workspaces = mock.Mock(return_value={137 'workspaces': [{'workspace_id': 'other', 'name': 'foo'},138 {'workspace_id': expected_workspace_id,139 'name': 'watson-online-store'}]})140 wos = watson_online_store.WatsonOnlineStore141 actual = wos.setup_conversation_workspace(self.conv_client,142 test_environ)143 self.conv_client.list_workspaces.assert_called_once()144 self.assertEqual(expected_workspace_id, actual)145 def test_setup_conversation_workspace_by_name_env(self):146 test_environ = {'WORKSPACE_NAME': 'foo name'}147 expected_workspace_id = 'this is the one'148 self.conv_client.list_workspaces = mock.Mock(return_value={149 'workspaces': [{'workspace_id': 'other', 'name': 'foo'},150 {'workspace_id': expected_workspace_id,151 'name': test_environ['WORKSPACE_NAME']}]})152 wos = watson_online_store.WatsonOnlineStore153 actual = wos.setup_conversation_workspace(self.conv_client,154 test_environ)155 self.conv_client.list_workspaces.assert_called_once()156 self.assertEqual(expected_workspace_id, actual)157 def test_setup_conversation_workspace_by_id(self):158 expected_workspace_id = 'testing with a ws ID'159 test_environ = {'WORKSPACE_ID': expected_workspace_id}160 self.conv_client.list_workspaces = mock.Mock(return_value={161 'workspaces': [{'workspace_id': 'other'},162 {'workspace_id': expected_workspace_id,163 'name': 'foo'}]})164 wos = watson_online_store.WatsonOnlineStore165 actual = wos.setup_conversation_workspace(166 self.conv_client, test_environ)167 self.conv_client.list_workspaces.assert_called_once()168 self.assertEqual(expected_workspace_id, actual)169 def test_setup_conversation_workspace_by_id_not_found(self):170 expected_workspace_id = 'testing with a ws ID'171 test_environ = {'WORKSPACE_ID': expected_workspace_id}172 self.conv_client.list_workspaces = mock.Mock(return_value={173 'workspaces': [{'workspace_id': 'other'},174 {'workspace_id': 'wrong again'}]})175 wos = watson_online_store.WatsonOnlineStore176 self.assertRaises(Exception,177 wos.setup_conversation_workspace,178 self.conv_client,179 test_environ)180 self.conv_client.list_workspaces.assert_called_once()181 def test_setup_conversation_workspace_create(self):182 expected_workspace_id = 'this was created'183 expected_workspace_name = 'and this was its name'184 test_environ = {'WORKSPACE_NAME': expected_workspace_name}185 self.conv_client.list_workspaces = mock.Mock(return_value={186 'workspaces': [{'workspace_id': 'other', 'name': 'any'}]})187 self.conv_client.create_workspace = mock.Mock(return_value={188 'workspace_id': expected_workspace_id})189 wos = watson_online_store.WatsonOnlineStore190 ws_json = {191 'counterexamples': 'c',192 'intents': 'i',193 'entities': 'e',194 'dialog_nodes': 'd',195 'metadata': 'm',196 'language': 'en',197 }198 wos.get_workspace_json = mock.Mock(return_value=ws_json)199 actual = wos.setup_conversation_workspace(200 self.conv_client, test_environ)201 self.conv_client.list_workspaces.assert_called_once()202 self.conv_client.create_workspace.assert_called_once_with(203 expected_workspace_name,204 'Conversation workspace created by watson-online-store.',205 ws_json['language'],206 intents=ws_json['intents'],207 entities=ws_json['entities'],208 dialog_nodes=ws_json['dialog_nodes'],209 counterexamples=ws_json['counterexamples'],210 metadata=ws_json['metadata'])211 self.assertEqual(expected_workspace_id, actual)212 def test_setup_discovery_environment_by_id(self):213 expected_environment_id = 'testing with a env ID'214 expected_collection_id = 'testing with a coll ID'215 test_environ = {'DISCOVERY_ENVIRONMENT_ID': expected_environment_id,216 self.fake_data_source + '_DISCO_COLLECTION_ID':217 expected_collection_id}218 self.discovery_client.get_environment = mock.Mock(return_value={219 'environment_id': expected_environment_id})220 self.discovery_client.get_collection = mock.Mock(return_value={221 'collection_id': expected_collection_id})222 wos = watson_online_store.WatsonOnlineStore223 actual_env, actual_coll = (224 wos.setup_discovery_collection(self.discovery_client,225 self.fake_data_source,226 test_environ))227 self.discovery_client.get_environment.assert_called_once()228 self.discovery_client.get_collection.assert_called_once()229 self.assertEqual(expected_environment_id, actual_env)230 self.assertEqual(expected_collection_id, actual_coll)231 def test_setup_discovery_environment_by_name_default(self):232 test_environ = {}233 expected_environment_id = 'this is the env'234 expected_collection_id = 'this is the coll'235 self.discovery_client.get_environments = mock.Mock(return_value={236 'environments': [{'environment_id': 'other', 'name': 'foo'},237 {'environment_id': expected_environment_id,238 'name': 'watson-online-store'}]})239 self.discovery_client.list_collections = mock.Mock(return_value={240 'collections': [{'collection_id': 'other', 'name': 'foo'},241 {'collection_id': expected_collection_id,242 'name': 'ibm-logo-store'}]})243 wos = watson_online_store.WatsonOnlineStore244 actual_env, actual_coll = (245 wos.setup_discovery_collection(self.discovery_client,246 self.fake_data_source,247 test_environ))248 self.discovery_client.get_environments.assert_called_once()249 self.discovery_client.list_collections.assert_called_once()250 self.assertEqual(expected_environment_id, actual_env)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful