Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
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
Пример #5
0
    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
Пример #6
0
    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
Пример #7
0
    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
Пример #8
0
    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
Пример #9
0
    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
Пример #10
0
    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'
Пример #11
0
    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'
Пример #12
0
    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'
Пример #13
0
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"
Пример #14
0
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"
Пример #15
0
    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'
Пример #16
0
    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'
Пример #17
0
    def test_add_is_idempotent(self, users):
        request = DummyRequest(params={"add": "agnos"})

        views.staff_add(request)

        assert users['agnos'].staff
Пример #18
0
    def test_add_makes_users_staff(self, pyramid_request, users):
        pyramid_request.params = {"add": "eva"}

        views.staff_add(pyramid_request)

        assert users['eva'].staff
Пример #19
0
    def test_add_makes_users_staff(self, users):
        request = DummyRequest(params={"add": "eva"})

        views.staff_add(request)

        assert users['eva'].staff
Пример #20
0
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")
Пример #21
0
    def test_add_is_idempotent(self, pyramid_request, users):
        pyramid_request.params = {"add": "agnos"}

        views.staff_add(pyramid_request)

        assert users['agnos'].staff
Пример #22
0
    def test_add_is_idempotent(self, users):
        request = DummyRequest(params={"add": "agnos"})

        views.staff_add(request)

        assert users['agnos'].staff
Пример #23
0
    def test_add_makes_users_staff(self, users):
        request = DummyRequest(params={"add": "eva"})

        views.staff_add(request)

        assert users['eva'].staff