示例#1
0
文件: admin_test.py 项目: hylhero/h
def test_admins_remove_404s_if_no_remove_param(User):
    User.admins.return_value = [Mock(username="******"),
                                Mock(username="******"),
                                Mock(username="******")]

    with pytest.raises(httpexceptions.HTTPNotFound):
        admin.admins_remove(DummyRequest())
示例#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

    admin.admins_remove(request)

    assert user.admin is True
示例#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"})

    admin.admins_remove(request)

    User.get_by_username.assert_called_once_with("fred")
示例#4
0
文件: admin_test.py 项目: ningyifan/h
def test_admins_remove_404s_if_no_remove_param(User):
    User.admins.return_value = [
        Mock(username="******"),
        Mock(username="******"),
        Mock(username="******")
    ]

    with pytest.raises(httpexceptions.HTTPNotFound):
        admin.admins_remove(DummyRequest())
示例#5
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

    admin.admins_remove(request)

    assert user.admin is True
示例#6
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"})
    request.route_url = Mock()

    admin.admins_remove(request)

    User.get_by_username.assert_called_once_with("fred")
示例#7
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

    admin.admins_remove(request)

    assert user.admin is False
示例#8
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"})
    request.route_url = Mock()
    user = Mock(admin=True)
    User.get_by_username.return_value = user

    admin.admins_remove(request)

    assert user.admin is False
示例#9
0
def test_admins_remove_returns_redirect_when_too_few_admins(User):
    User.admins.return_value = [Mock(username="******")]
    request = DummyRequest(params={"remove": "fred"})

    response = admin.admins_remove(request)

    assert isinstance(response, httpexceptions.HTTPSeeOther)
示例#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 = admin.admins_remove(request)

    assert isinstance(response, httpexceptions.HTTPSeeOther)
示例#11
0
def test_staff_remove_returns_redirect_on_success(User):
    User.admins.return_value = [Mock(username="******"),
                                Mock(username="******"),
                                Mock(username="******")]
    request = DummyRequest(params={"remove": "fred"})

    response = admin.admins_remove(request)

    assert isinstance(response, httpexceptions.HTTPSeeOther)
示例#12
0
def test_staff_remove_returns_redirect_on_success(User):
    User.admins.return_value = [Mock(username="******"),
                                Mock(username="******"),
                                Mock(username="******")]
    request = DummyRequest(params={"remove": "fred"})
    request.route_url = Mock()

    response = admin.admins_remove(request)

    assert isinstance(response, httpexceptions.HTTPSeeOther)