Example #1
0
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
Example #2
0
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
Example #3
0
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")
Example #4
0
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")
Example #5
0
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
Example #6
0
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
Example #7
0
    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'
Example #8
0
    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'
Example #9
0
    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"
Example #10
0
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)
Example #11
0
    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'
Example #12
0
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)
Example #13
0
    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
Example #14
0
    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
Example #15
0
    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
Example #16
0
    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
Example #17
0
    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
Example #18
0
    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
Example #19
0
    def test_remove_is_idempotent(self, users):
        request = DummyRequest(params={"remove": "eva"})

        views.admins_remove(request)

        assert not users['eva'].admin
Example #20
0
    def test_remove_makes_users_not_admins(self, users):
        request = DummyRequest(params={"remove": "cristof"})

        views.admins_remove(request)

        assert not users['cristof'].admin
Example #21
0
    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
Example #22
0
    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
Example #23
0
    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
Example #24
0
    def test_remove_is_idempotent(self, pyramid_request, users):
        pyramid_request.params = {"remove": "eva"}

        views.admins_remove(pyramid_request)

        assert not users["eva"].admin
Example #25
0
    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