def test_add_before_or_after_after(self, run): request = Mock(content_type='', method='', accept=[''], user=None) view = BaseView( context={}, request=request, _query_params={'foo': 'bar'}) callable_ = lambda x: x view.add_before_or_after_call( action='foo', _callable=callable_, pos=None, before=False) assert callable_ in view._after_calls['foo']
def test_add_before_or_after_not_callable(self, run): request = Mock(content_type='', method='', accept=[''], user=None) view = BaseView( context={}, request=request, _query_params={'foo': 'bar'}) with pytest.raises(ValueError) as ex: view.add_before_or_after_call( action='foo', _callable='asdasd', pos=None, before=False) assert str(ex.value) == 'asdasd is not a callable'