How to use the zhmcclient.NoUniqueMatch function in zhmcclient

To help you get started, we’ve selected a few zhmcclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_nouniquematch_repr(self, filter_args):
        """All tests for NoUniqueMatch.__repr__()."""

        cpc = self.client.cpcs.find(name='cpc_1')
        manager = cpc.adapters
        resources = manager.list()

        exc = NoUniqueMatch(filter_args, manager, resources)

        classname = exc.__class__.__name__

        # Execute the code to be tested
        repr_str = repr(exc)

        # We check the one-lined string just roughly
        repr_str = repr_str.replace('\n', '\\n')
        assert re.match(r'^{}\s*\(.*\)$'.format(classname), repr_str)
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_nouniquematch_str(self, filter_args):
        """All tests for NoUniqueMatch.__str__()."""

        cpc = self.client.cpcs.find(name='cpc_1')
        manager = cpc.adapters
        resources = manager.list()

        exc = NoUniqueMatch(filter_args, manager, resources)

        exp_str = str(exc.args[0])

        # Execute the code to be tested
        str_str = str(exc)

        assert str_str == exp_str
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_manager.py View on Github external
def test_find_str_two(self):
        """Test BaseManager.find() with two resources matching by a
        string-typed (non-name) resource property."""
        with pytest.raises(NoUniqueMatch):

            self.manager.find(same="fake-same")
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_manager.py View on Github external
def test_find_int_two(self):
        """Test BaseManager.find() with two resources matching by a
        string-typed (non-name) resource property."""
        with pytest.raises(NoUniqueMatch):

            self.manager.find(int_same=42)
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
filter_args = args[0]

        cpc = self.client.cpcs.find(name='cpc_1')
        manager = cpc.adapters
        resources = manager.list()
        resource_uris = [r.uri for r in resources]

        _args = list(args)
        _args.append(manager)
        _args.append(resources)

        posargs, kwargs = func_args(_args, arg_names)

        # Execute the code to be tested
        exc = NoUniqueMatch(*posargs, **kwargs)

        assert isinstance(exc, Error)
        assert len(exc.args) == 1
        assert isinstance(exc.args[0], six.string_types)
        # auto-generated message, we don't expect a particular value
        assert exc.filter_args == filter_args
        assert exc.manager == manager
        assert exc.resources == resources
        assert exc.resource_uris == resource_uris
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_nouniquematch_str_def(self, filter_args):
        """All tests for NoUniqueMatch.str_def()."""

        cpc = self.client.cpcs.find(name='cpc_1')
        manager = cpc.adapters
        resources = manager.list()

        exc = NoUniqueMatch(filter_args, manager, resources)

        classname = exc.__class__.__name__

        # Execute the code to be tested
        str_def = exc.str_def()

        str_def = ' ' + str_def
        assert str_def.find(' classname={!r};'.format(classname)) >= 0
        assert str_def.find(' resource_classname={!r};'.
                            format(manager.resource_class.__name__)) >= 0
        assert str_def.find(' filter_args={!r};'.format(filter_args)) >= 0
        assert str_def.find(' parent_classname={!r};'.
                            format(manager.parent.__class__.__name__)) >= 0
        assert str_def.find(' parent_name={!r};'.
                            format(manager.parent.name)) >= 0
        assert str_def.find(' message=') >= 0