def test_get_success_url(self, kwargs):
        success_url = '/'.join('{{{0}}}'.format(k) for k in iterkeys(kwargs))

        instance = sqlalchemy.DeletionMixin()
        instance.success_url = success_url or None
        instance.object = type('foo', (object,), {})()

        for k, v in iteritems(kwargs):
            setattr(instance.object, k, v)

        if not success_url:
            with pytest.raises(NotImplementedError) as excinfo:
                instance.get_success_url()

            error = ('DeletionMixin requires either a definition of '
                     "'success_url' or an implementation of "
                     "'get_success_url()'")

            assert excinfo.value.args[0] == error
        else:
            assert instance.get_success_url() == success_url.format(**kwargs)
    def test_init(self, kwargs):
        instance = core.View(**kwargs)

        for k, v in iteritems(kwargs):
            assert getattr(instance, k) == v
Exemplo n.º 3
0
 def __init__(self, **kwargs):
     for k, v in iteritems(kwargs):
         setattr(self, k, v)
 def __init__(self, **kwargs):
     for k, v in iteritems(kwargs):
         setattr(self, k, v)