def test_add_flashes_when_user_not_found(self): request = DummyRequest(params={"add": "florp"}) request.session.flash = Mock() views.admins_add(request) assert request.session.flash.call_count == 1
def test_add_flashes_when_user_not_found(self, pyramid_request): pyramid_request.params = {"add": "florp"} pyramid_request.session.flash = mock.Mock() views.admins_add(pyramid_request) assert pyramid_request.session.flash.call_count == 1
def test_admins_add_flashes_on_NoSuchUserError(make_admin): make_admin.side_effect = accounts.NoSuchUserError request = DummyRequest(params={"add": "seanh"}) request.session.flash = Mock() views.admins_add(request) assert request.session.flash.call_count == 1
def test_add_strips_spaces(self, pyramid_request, users): pyramid_request.params = { "add": " david ", "authority": " example.com " } views.admins_add(pyramid_request) assert users['david'].admin
def test_add_is_idempotent(self, pyramid_request, users): pyramid_request.params = { "add": "agnos", "authority": pyramid_request.auth_domain, } views.admins_add(pyramid_request) assert users['agnos'].admin
def test_add_makes_users_admins(self, pyramid_request, users): pyramid_request.params = { "add": "eva", "authority": 'foo.org', } views.admins_add(pyramid_request) assert users['eva'].admin
def test_admins_add_returns_index_on_success(admins_index): request = DummyRequest(params={"add": "seanh"}) admins_index.return_value = "expected data" result = views.admins_add(request) assert result == "expected data"
def test_add_redirects_to_index_when_user_not_found(self): request = DummyRequest(params={"add": "florp"}) result = views.admins_add(request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/admins'
def test_add_redirects_to_index(self, pyramid_request): pyramid_request.params = {"add": "eva"} result = views.admins_add(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/admins'
def test_add_redirects_to_index_when_user_not_found(self, pyramid_request): pyramid_request.params = {"add": "florp"} result = views.admins_add(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == "/adm/admins"
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 = views.admins_add(request) assert result == "expected data"
def test_add_redirects_to_index(self, pyramid_request): pyramid_request.params = { "add": "eva", "authority": pyramid_request.auth_domain, } result = views.admins_add(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/admins'
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.admins_add(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/admins'
def test_add_makes_users_admins(self, pyramid_request, users): pyramid_request.params = {"add": "eva"} views.admins_add(pyramid_request) assert users['eva'].admin
def test_add_strips_spaces(self, pyramid_request, users): pyramid_request.params = {"add": " david ", "authority": " example.com "} views.admins_add(pyramid_request) assert users['david'].admin
def test_admins_add_calls_make_admin(make_admin): request = DummyRequest(params={"add": "seanh"}) views.admins_add(request) make_admin.assert_called_once_with("seanh")
def test_add_makes_users_admins(self, pyramid_request, users): pyramid_request.params = {"add": "eva"} views.admins_add(pyramid_request) assert users["eva"].admin
def test_add_is_idempotent(self, users): request = DummyRequest(params={"add": "agnos"}) views.admins_add(request) assert users['agnos'].admin
def test_add_makes_users_admins(self, users): request = DummyRequest(params={"add": "eva"}) views.admins_add(request) assert users['eva'].admin
def test_add_is_idempotent(self, pyramid_request, users): pyramid_request.params = {"add": "agnos"} views.admins_add(pyramid_request) assert users["agnos"].admin
def test_add_is_idempotent(self, pyramid_request, users): pyramid_request.params = {"add": "agnos"} views.admins_add(pyramid_request) assert users['agnos'].admin