Esempio n. 1
0
    def test_invoke_echo_long_running_false_method(self):
        connector = get_local_connector(MockupApiProvider())
        self.assertTrue(isinstance(connector, Connector))

        iface = MockIface(StubConfiguration(connector))
        self.assertTrue(isinstance(iface, VapiInterface))

        self.assertEqual(iface.echo_long_running(message='hello'), 'hello')
Esempio n. 2
0
    def test_invoke_echo_long_running_method(self):
        connector = get_local_connector(MockupApiProvider())
        self.assertTrue(isinstance(connector, Connector))

        iface = MockIface(StubConfiguration(connector))
        self.assertTrue(isinstance(iface, VapiInterface))

        result = iface.echo_long_running_task(message='hello')
        self.assertNotEqual(result, 'hello')
        try:
            uuid.UUID(result, version=4)
        except ValueError:
            # There's no assertNotRaises so explicitly fail assert
            # in case a ValueError is thrown for invalid uuid.
            self.assertTrue(False)
Esempio n. 3
0
    def _build(self, api_provider):
        """
        Get the metamodel metadata and process it

        :type  api_provider: :class:`vmware.vapi.core.ApiProvider`
        :param api_provider: ApiProvider to get the metadata
        """
        local_connector = get_local_connector(api_provider)
        stub_config = StubConfigurationFactory.new_std_configuration(
            local_connector)
        component_svc = Component(stub_config)
        components = component_svc.list()
        for component_id in components:
            component_data = component_svc.get(component_id)
            self._process_component_info(component_data.info)
Esempio n. 4
0
 def test_report_success(self):
     config = StubConfiguration(get_local_connector(MockupApiProvider()))
     operations = {
         report_vapi_success: {
             'input_type': StructType(report_vapi_success, {}),
             'output_type': BooleanType(),
             'errors': {},
             'input_value_validator_list': [],
             'output_validator_list': [],
             'task_type': TaskType.NONE,
         }
     }
     stub = ApiInterfaceStub('mockup_interface',
                             config=config,
                             operations=operations)
     self.assertEqual(
         stub.native_invoke(ctx=config.connector.new_context(),
                            method_name=report_vapi_success,
                            kwargs={}), True)
Esempio n. 5
0
 def test_report_unexpected_error(self):
     config = StubConfiguration(get_local_connector(MockupApiProvider()))
     operations = {
         nonexistent_method: {
             'input_type': StructType(nonexistent_method, {}),
             'output_type': BooleanType(),
             'errors': {
                 not_found: not_found_error_type
             },
             'input_value_validator_list': [],
             'output_validator_list': [],
             'task_type': TaskType.NONE,
         }
     }
     stub = ApiInterfaceStub('mockup_interface',
                             config=config,
                             operations=operations)
     self.assertRaises(VapiError, stub.native_invoke,
                       config.connector.new_context(), nonexistent_method,
                       {})
Esempio n. 6
0
 def test_json_client_provider_for_swagger_services(self):
     connector = get_local_connector(MockupApiProvider())
     iface = MockRestIface(StubConfiguration(connector))
     self.assertRaises(CoreException, iface.echo, message='hello')
Esempio n. 7
0
 def test_invoke_invalid_method(self):
     connector = get_local_connector(MockupApiProvider())
     iface = MockIface(StubConfiguration(connector))
     self.assertRaises(Exception, iface.invalid)