def test_staff_remove_calls_get_by_username(User): User.staff_members.return_value = [Mock(username="******"), Mock(username="******"), Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) admin.staff_remove(request) User.get_by_username.assert_called_once_with("fred")
def test_staff_remove_calls_get_by_username(User): User.staff_members.return_value = [Mock(username="******"), Mock(username="******"), Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) request.route_url = Mock() admin.staff_remove(request) User.get_by_username.assert_called_once_with("fred")
def test_staff_remove_sets_staff_to_False(User): User.staff_members.return_value = [Mock(username="******"), Mock(username="******"), Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) user = Mock(staff=True) User.get_by_username.return_value = user admin.staff_remove(request) assert user.staff is False
def test_staff_remove_sets_staff_to_False(User): User.staff_members.return_value = [Mock(username="******"), Mock(username="******"), Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) request.route_url = Mock() user = Mock(staff=True) User.get_by_username.return_value = user admin.staff_remove(request) assert user.staff is False
def test_staff_remove_404s_if_no_remove_param(): with pytest.raises(httpexceptions.HTTPNotFound): admin.staff_remove(DummyRequest())