Exemplo n.º 1
0
    def test_get_sets_default_values(self, pyramid_request):
        controller = OrganizationCreateController(pyramid_request)

        response = controller.get()

        assert response["form"] == {
            "authority": pyramid_request.default_authority
        }
Exemplo n.º 2
0
    def test_post_redirects_to_list_view(
        self, pyramid_request, handle_form_submission, matchers
    ):
        handle_form_submission.side_effect = self.call_on_success
        controller = OrganizationCreateController(pyramid_request)

        response = controller.post()

        list_url = pyramid_request.route_url("admin.organizations")
        assert response == matchers.Redirect302To(list_url)
Exemplo n.º 3
0
    def test_post_redirects_to_list_view(self, pyramid_request, handle_form_submission, matchers):
        def call_on_success(request, form, on_success, on_failure):
            return on_success({'name': 'New org',
                               'authority': 'example.org',
                               'logo': '<svg>a logo</svg>'})
        handle_form_submission.side_effect = call_on_success
        ctrl = OrganizationCreateController(pyramid_request)

        response = ctrl.post()

        list_url = pyramid_request.route_url('admin.organizations')
        assert response == matchers.Redirect302To(list_url)
Exemplo n.º 4
0
    def test_post_creates_org(self, pyramid_request, handle_form_submission):
        handle_form_submission.side_effect = self.call_on_success
        controller = OrganizationCreateController(pyramid_request)

        controller.post()

        org = (
            pyramid_request.db.query(Organization)
            .filter_by(name="New organization")
            .one()
        )
        assert org.authority == "example.organization"
        assert org.logo == "<svg>a logo</svg>"
Exemplo n.º 5
0
    def test_post_creates_org(self, pyramid_request, handle_form_submission):
        def call_on_success(request, form, on_success, on_failure):
            return on_success({'name': 'New org',
                               'authority': 'example.org',
                               'logo': '<svg>a logo</svg>'})
        handle_form_submission.side_effect = call_on_success
        ctrl = OrganizationCreateController(pyramid_request)

        ctrl.post()

        org = (pyramid_request.db.query(Organization)
                              .filter_by(name='New org')
                              .one())
        assert org.authority == 'example.org'
        assert org.logo == '<svg>a logo</svg>'
Exemplo n.º 6
0
    def test_post_redirects_to_list_view(self, pyramid_request,
                                         handle_form_submission, matchers):
        def call_on_success(request, form, on_success, on_failure):
            return on_success({
                "name": "New organization",
                "authority": "example.organization",
                "logo": "<svg>a logo</svg>",
            })

        handle_form_submission.side_effect = call_on_success
        controller = OrganizationCreateController(pyramid_request)

        response = controller.post()

        list_url = pyramid_request.route_url("admin.organizations")
        assert response == matchers.Redirect302To(list_url)
Exemplo n.º 7
0
    def test_post_creates_org(self, pyramid_request, handle_form_submission):
        def call_on_success(request, form, on_success, on_failure):
            return on_success({
                "name": "New organization",
                "authority": "example.organization",
                "logo": "<svg>a logo</svg>",
            })

        handle_form_submission.side_effect = call_on_success
        controller = OrganizationCreateController(pyramid_request)

        controller.post()

        org = (pyramid_request.db.query(Organization).filter_by(
            name="New organization").one())
        assert org.authority == "example.organization"
        assert org.logo == "<svg>a logo</svg>"
Exemplo n.º 8
0
    def test_get_sets_default_values(self, pyramid_request):
        ctrl = OrganizationCreateController(pyramid_request)

        ctx = ctrl.get()

        assert ctx['form'] == {'authority': pyramid_request.default_authority}