コード例 #1
0
    def test_notfound_str_def(self, filter_args):
        """All tests for NotFound.str_def()."""

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

        exc = NotFound(filter_args, manager)

        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
コード例 #2
0
    def test_notfound_str(self, filter_args):
        """All tests for NotFound.__str__()."""

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

        exc = NotFound(filter_args, manager)

        exp_str = str(exc.args[0])

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

        assert str_str == exp_str
コード例 #3
0
    def test_notfound_repr(self, filter_args):
        """All tests for NotFound.__repr__()."""

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

        exc = NotFound(filter_args, manager)

        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)
コード例 #4
0
    def test_notfound_initial_attrs(self, arg_names, args):
        """Test initial attributes of NotFound."""

        filter_args = args[0]

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

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

        posargs, kwargs = func_args(_args, arg_names)

        # Execute the code to be tested
        exc = NotFound(*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