コード例 #1
0
 def test_interface_show_error(self, fixture_cmd, serviceclientemptyresult,
                               target_interface):
     with pytest.raises(CLIError):
         subject.iot_pnp_interface_show(
             fixture_cmd,
             interface=target_interface,
             repo_endpoint=mock_target["entity"],
             repo_id=mock_target["repository_id"],
         )
コード例 #2
0
 def test_interface_show_error(self, fixture_cmd,
                               serviceclient_generic_error,
                               target_interface):
     with pytest.raises(CLIError):
         result = subject.iot_pnp_interface_show(
             fixture_cmd,
             interface=target_interface,
             repo_endpoint=mock_target['entity'],
             repo_id=mock_target['repository_id'])
コード例 #3
0
def _pnp_interface_elements(cmd, interface, target_type, repo_endpoint, repo_id, login):
    interface_elements = []
    results = iot_pnp_interface_list(cmd, repo_endpoint, repo_id, interface, login=login)
    if results:
        interface_def = iot_pnp_interface_show(cmd, interface, repo_endpoint, repo_id, login)
        interface_contents = interface_def.get('contents')
        for content in interface_contents:
            if isinstance(content.get('@type'), list) and target_type in content.get('@type'):
                interface_elements.append(content)
            elif content.get('@type') == target_type:
                interface_elements.append(content)
    return interface_elements
コード例 #4
0
    def test_interface_show(self, fixture_cmd, serviceclient,
                            target_interface):
        result = subject.iot_pnp_interface_show(
            fixture_cmd,
            interface=target_interface,
            repo_endpoint=mock_target['entity'],
            repo_id=mock_target['repository_id'])
        args = serviceclient.call_args
        url = args[0][0].url
        method = args[0][0].method
        headers = args[0][0].headers

        assert method == 'GET'
        assert '{}/models/{}?'.format(
            _repo_endpoint, url_encode_str(_pnp_generic_interface_id,
                                           plus=True)) in url
        assert 'repositoryId={}'.format(_repo_id) in url
        assert json.dumps(result)
        assert headers.get('Authorization')