def test_add_flashes_when_user_not_found(self, pyramid_request): pyramid_request.params = {"add": "florp"} pyramid_request.session.flash = mock.Mock() views.staff_add(pyramid_request) assert pyramid_request.session.flash.call_count == 1
def test_add_flashes_when_user_not_found(self): request = DummyRequest(params={"add": "florp"}) request.session.flash = Mock() views.staff_add(request) assert request.session.flash.call_count == 1
def test_staff_add_flashes_on_NoSuchUserError(make_staff): make_staff.side_effect = accounts.NoSuchUserError request = DummyRequest(params={"add": "seanh"}) request.session.flash = Mock() views.staff_add(request) assert request.session.flash.call_count == 1
def test_add_is_idempotent(self, pyramid_request, users): pyramid_request.params = { "add": "agnos", "authority": pyramid_request.auth_domain } views.staff_add(pyramid_request) assert users['agnos'].staff
def test_add_strips_spaces(self, pyramid_request, users): pyramid_request.params = { "add": " eva ", "authority": " foo.org " } views.staff_add(pyramid_request) assert users['eva'].staff
def test_add_flashes_when_user_not_found(self, pyramid_request): pyramid_request.params = { "add": "florp", "authority": pyramid_request.auth_domain } pyramid_request.session.flash = mock.Mock() views.staff_add(pyramid_request) assert pyramid_request.session.flash.call_count == 1
def test_add_redirects_to_index(self, pyramid_request): pyramid_request.params = {"add": "eva"} result = views.staff_add(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/staff'
def test_add_redirects_to_index_when_user_not_found(self): request = DummyRequest(params={"add": "florp"}) result = views.staff_add(request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/staff'
def test_staff_add_returns_index_on_success(staff_index): request = DummyRequest(params={"add": "seanh"}) staff_index.return_value = "expected data" result = views.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 = views.staff_add(request) assert result == "expected data"
def test_add_redirects_to_index_when_user_not_found(self, pyramid_request): pyramid_request.params = { "add": "florp", "authority": pyramid_request.auth_domain } result = views.staff_add(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/staff'
def test_add_is_idempotent(self, users): request = DummyRequest(params={"add": "agnos"}) views.staff_add(request) assert users['agnos'].staff
def test_add_makes_users_staff(self, pyramid_request, users): pyramid_request.params = {"add": "eva"} views.staff_add(pyramid_request) assert users['eva'].staff
def test_add_makes_users_staff(self, users): request = DummyRequest(params={"add": "eva"}) views.staff_add(request) assert users['eva'].staff
def test_staff_add_calls_make_staff(make_staff): request = DummyRequest(params={"add": "seanh"}) views.staff_add(request) make_staff.assert_called_once_with("seanh")
def test_add_is_idempotent(self, pyramid_request, users): pyramid_request.params = {"add": "agnos"} views.staff_add(pyramid_request) assert users['agnos'].staff