def test_admins_remove_does_not_delete_last_admin(User): User.admins.return_value = [Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) user = Mock(admin=True) User.get_by_username.return_value = user views.admins_remove(request) assert user.admin is True
def test_admins_remove_calls_get_by_username(User): User.admins.return_value = [Mock(username="******"), Mock(username="******"), Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) views.admins_remove(request) User.get_by_username.assert_called_once_with("fred")
def test_admins_remove_calls_get_by_username(User): User.admins.return_value = [ Mock(username="******"), Mock(username="******"), Mock(username="******") ] request = DummyRequest(params={"remove": "fred"}) views.admins_remove(request) User.get_by_username.assert_called_once_with("fred")
def test_admins_remove_sets_admin_to_False(User): User.admins.return_value = [Mock(username="******"), Mock(username="******"), Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) user = Mock(admin=True) User.get_by_username.return_value = user views.admins_remove(request) assert user.admin is False
def test_admins_remove_sets_admin_to_False(User): User.admins.return_value = [ Mock(username="******"), Mock(username="******"), Mock(username="******") ] request = DummyRequest(params={"remove": "fred"}) user = Mock(admin=True) User.get_by_username.return_value = user views.admins_remove(request) assert user.admin is False
def test_remove_redirects_to_index(self, pyramid_request): pyramid_request.params = {"remove": "acct:[email protected]"} result = views.admins_remove(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/admins'
def test_remove_redirects_to_index_when_user_not_found(self, pyramid_request): pyramid_request.params = {"remove": "florp"} result = views.admins_remove(pyramid_request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == "/adm/admins"
def test_admins_remove_returns_redirect_when_too_few_admins(User): User.admins.return_value = [Mock(username="******")] request = DummyRequest(params={"remove": "fred"}) response = views.admins_remove(request) assert isinstance(response, httpexceptions.HTTPSeeOther)
def test_remove_redirects_to_index_when_user_not_found(self): request = DummyRequest(params={"remove": "florp"}) result = views.admins_remove(request) assert isinstance(result, httpexceptions.HTTPSeeOther) assert result.location == '/adm/admins'
def test_remove_will_not_remove_last_admin(self, pyramid_request, users): pyramid_request.params = {"remove": "cristof"} views.admins_remove(pyramid_request) pyramid_request.params = {"remove": "bojan"} views.admins_remove(pyramid_request) pyramid_request.params = {"remove": "agnos"} views.admins_remove(pyramid_request) assert users['agnos'].admin
def test_remove_will_not_remove_last_admin(self, pyramid_request, users): pyramid_request.params = {"remove": "acct:[email protected]"} views.admins_remove(pyramid_request) pyramid_request.params = {"remove": "acct:[email protected]"} views.admins_remove(pyramid_request) pyramid_request.params = {"remove": "acct:[email protected]"} views.admins_remove(pyramid_request) assert users['agnos'].admin
def test_remove_will_not_remove_last_admin(self, pyramid_request, users): pyramid_request.params = {"remove": "cristof"} views.admins_remove(pyramid_request) pyramid_request.params = {"remove": "bojan"} views.admins_remove(pyramid_request) pyramid_request.params = {"remove": "agnos"} views.admins_remove(pyramid_request) assert users["agnos"].admin
def test_remove_makes_users_not_admins(self, pyramid_request, users): pyramid_request.params = {"remove": "acct:[email protected]"} views.admins_remove(pyramid_request) assert not users['cristof'].admin
def test_remove_will_not_remove_last_admin(self, users): views.admins_remove(DummyRequest(params={"remove": "cristof"})) views.admins_remove(DummyRequest(params={"remove": "bojan"})) views.admins_remove(DummyRequest(params={"remove": "agnos"})) assert users['agnos'].admin
def test_remove_is_idempotent(self, users): request = DummyRequest(params={"remove": "eva"}) views.admins_remove(request) assert not users['eva'].admin
def test_remove_makes_users_not_admins(self, users): request = DummyRequest(params={"remove": "cristof"}) views.admins_remove(request) assert not users['cristof'].admin
def test_remove_is_idempotent(self, pyramid_request, users): pyramid_request.params = {"remove": "acct:[email protected]"} views.admins_remove(pyramid_request) assert not users['eva'].admin
def test_remove_is_idempotent(self, pyramid_request, users): pyramid_request.params = {"remove": "eva"} views.admins_remove(pyramid_request) assert not users["eva"].admin
def test_remove_makes_users_not_admins(self, pyramid_request, users): pyramid_request.params = {"remove": "cristof"} views.admins_remove(pyramid_request) assert not users["cristof"].admin