def test_nouniquematch_initial_attrs(self, arg_names, args): """Test initial attributes of NoUniqueMatch.""" 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
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
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
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)