def test_admins_add_flashes_on_NoSuchUserError(make_admin): make_admin.side_effect = accounts.NoSuchUserError request = DummyRequest(params={"add": "seanh"}) request.session.flash = Mock() admin.admins_add(request) assert request.session.flash.call_count == 1
def test_admins_add_returns_index_on_success(admins_index): request = DummyRequest(params={"add": "seanh"}) admins_index.return_value = "expected data" result = admin.admins_add(request) assert result == "expected data"
def test_admins_add_returns_index_on_NoSuchUserError(make_admin, admins_index): make_admin.side_effect = accounts.NoSuchUserError admins_index.return_value = "expected data" request = DummyRequest(params={"add": "seanh"}) result = admin.admins_add(request) assert result == "expected data"
def test_admins_add_calls_make_admin(make_admin): request = DummyRequest(params={"add": "seanh"}) admin.admins_add(request) make_admin.assert_called_once_with("seanh")
def test_admins_add_when_no_add_param(): """It should 404 if the request has no "add" param.""" with pytest.raises(httpexceptions.HTTPNotFound): admin.admins_add(DummyRequest())