def test_staff_add_flashes_on_NoSuchUserError(make_staff): make_staff.side_effect = accounts.NoSuchUserError request = DummyRequest(params={"add": "seanh"}) request.session.flash = Mock() admin.staff_add(request) assert request.session.flash.call_count == 1
def test_staff_add_returns_index_on_success(staff_index): request = DummyRequest(params={"add": "seanh"}) staff_index.return_value = "expected data" result = admin.staff_add(request) assert result == "expected data"
def test_staff_add_returns_index_on_NoSuchUserError(make_staff, staff_index): make_staff.side_effect = accounts.NoSuchUserError staff_index.return_value = "expected data" request = DummyRequest(params={"add": "seanh"}) result = admin.staff_add(request) assert result == "expected data"
def test_staff_add_calls_make_staff(make_staff): request = DummyRequest(params={"add": "seanh"}) admin.staff_add(request) make_staff.assert_called_once_with("seanh")
def test_staff_add_when_no_add_param(): """It should 404 if the request has no "add" param.""" with pytest.raises(httpexceptions.HTTPNotFound): admin.staff_add(DummyRequest())