def test_update_protocol_plugin(self, mock_plugin_init, mock_list_secrets, *args): plugin_version = '1.2' update_options = { 'test': 'xxxxx' } mock_plugin_init.return_value = { 'metadata': { 'data_type': 'PLAIN_TEXT', 'data': { 'schema': { 'properties': { 'phone_number': { 'minLength': 10, 'title': 'Phone Number', 'type': 'string', 'pattern': '^01(?:0|1|[6-9])[.-]?(\\d{3}|\\d{4}[.-]?(\\d{4})$' } }, 'required': [ 'phone_number' ], 'type': 'object' } } } } mock_list_secrets.return_value = { 'results': [{ 'secret_id': utils.generate_id('secret') }], 'total_count': 1 } protocol_vo = ProtocolFactory(domain_id=self.domain_id) params = { 'protocol_id': protocol_vo.protocol_id, 'version': plugin_version, 'options': update_options, 'domain_id': self.domain_id } self.transaction.method = 'update_plugin' protocol_svc = ProtocolService(transaction=self.transaction) new_protocol_vo = protocol_svc.update_plugin(params.copy()) print_data(new_protocol_vo.to_dict(), 'test_update_protocol_plugin') ProtocolInfo(new_protocol_vo) self.assertIsInstance(new_protocol_vo, Protocol) self.assertEqual(new_protocol_vo.protocol_id, protocol_vo.protocol_id) self.assertEqual(params['version'], new_protocol_vo.plugin_info.version) self.assertEqual(params['options'], new_protocol_vo.plugin_info.options)
def test_update_protocol_plugin(self, mock_plugin_init, mock_list_secrets, *args): plugin_version = '1.2' update_options = {'test': 'xxxxx'} mock_plugin_init.return_value = { 'metadata': { 'supported_resource_type': ['inventory.Server'], 'supported_stat': ['AVERAGE', 'MAX', 'MIN'], 'required_keys': ['reference.resource_id'] } } mock_list_secrets.return_value = { 'results': [{ 'secret_id': utils.generate_id('secret') }], 'total_count': 1 } protocol_vo = ProtocolFactory(domain_id=self.domain_id) params = { 'protocol_id': protocol_vo.protocol_id, 'version': plugin_version, 'options': update_options, 'domain_id': self.domain_id } self.transaction.method = 'update_plugin' protocol_svc = ProtocolService(transaction=self.transaction) new_protocol_vo = protocol_svc.update_plugin(params.copy()) print_data(new_protocol_vo.to_dict(), 'test_update_protocol_plugin') ProtocolInfo(new_protocol_vo) self.assertIsInstance(new_protocol_vo, Protocol) self.assertEqual(new_protocol_vo.protocol_id, protocol_vo.protocol_id) self.assertEqual(params['version'], new_protocol_vo.plugin_info.version) self.assertEqual(params['options'], new_protocol_vo.plugin_info.options)