Beispiel #1
0
    def test_it_returns_updated_group_formatted_with_presenter(
            self, pyramid_request, GroupContext, GroupJSONPresenter, group):
        views.update(group, pyramid_request)

        GroupJSONPresenter.assert_called_once_with(GroupContext.return_value)
        GroupJSONPresenter.return_value.asdict.assert_called_once_with(
            expand=["organization"])
Beispiel #2
0
    def test_it_passes_request_params_to_group_update_service(
        self, group, pyramid_request, UpdateGroupAPISchema, group_update_service
    ):
        patch_payload = {"name": "My Group", "description": "How about that?"}
        UpdateGroupAPISchema.return_value.validate.return_value = patch_payload
        views.update(group, pyramid_request)

        group_update_service.update.assert_called_once_with(group, **patch_payload)
Beispiel #3
0
    def test_it_creates_group_context_from_updated_group(
            self, pyramid_request, GroupContext, group_update_service):
        my_group = mock.Mock()
        group_update_service.update.return_value = my_group

        views.update(my_group, pyramid_request)

        GroupContext.assert_called_with(my_group, pyramid_request)
Beispiel #4
0
    def test_it_passes_request_params_to_group_update_service(
        self, group, pyramid_request, UpdateGroupAPISchema, group_update_service
    ):
        patch_payload = {"name": "My Group", "description": "How about that?"}
        UpdateGroupAPISchema.return_value.validate.return_value = patch_payload
        views.update(group, pyramid_request)

        group_update_service.update.assert_called_once_with(group, **patch_payload)
Beispiel #5
0
    def test_it_does_not_raise_ConflictError_if_duplicate_is_same_group(
            self, pyramid_request, UpdateGroupAPISchema, group_service,
            factories):
        group = factories.Group(authority_provided_id="something_else",
                                authority="example.com")
        group_service.fetch.return_value = group

        views.update(group, pyramid_request)
Beispiel #6
0
    def test_it_returns_updated_group_formatted_with_presenter(
        self, pyramid_request, GroupContext, GroupJSONPresenter, group
    ):
        views.update(group, pyramid_request)

        GroupJSONPresenter.assert_called_once_with(GroupContext.return_value)
        GroupJSONPresenter.return_value.asdict.assert_called_once_with(
            expand=["organization", "scopes"]
        )
Beispiel #7
0
    def test_it_creates_group_context_from_updated_group(
        self, pyramid_request, GroupContext, group_update_service
    ):
        my_group = mock.Mock()
        group_update_service.update.return_value = my_group

        views.update(my_group, pyramid_request)

        GroupContext.assert_called_with(my_group, pyramid_request)
Beispiel #8
0
    def test_it_does_not_raise_HTTPConflict_if_duplicate_is_same_group(
        self, pyramid_request, UpdateGroupAPISchema, group_service, factories
    ):
        group = factories.Group(
            authority_provided_id="something_else", authority="example.com"
        )
        group_service.fetch.return_value = group

        views.update(group, pyramid_request)
Beispiel #9
0
    def test_it_raises_HTTPConflict_on_duplicate(self, pyramid_request,
                                                 UpdateGroupAPISchema, context,
                                                 group_service, factories):
        # Return a different pre-existing group when we search by id
        group_service.fetch.return_value = factories.Group(
            authority_provided_id="different_id",
            authority=context.group.authority)

        with pytest.raises(HTTPConflict,
                           match="group with groupid.*already exists"):
            views.update(context, pyramid_request)
Beispiel #10
0
    def test_it_raises_ConflictError_on_duplicate(self, pyramid_request,
                                                  UpdateGroupAPISchema,
                                                  group_service, factories):

        pre_existing_group = factories.Group(authority_provided_id="something",
                                             authority="example.com")
        group = factories.Group(authority_provided_id="something_else",
                                authority="example.com")
        group_service.fetch.return_value = pre_existing_group

        with pytest.raises(ConflictError,
                           match="group with groupid.*already exists"):
            views.update(group, pyramid_request)
Beispiel #11
0
    def test_it_raises_HTTPConflict_on_duplicate(
        self, pyramid_request, UpdateGroupAPISchema, group_service, factories
    ):

        pre_existing_group = factories.Group(
            authority_provided_id="something", authority="example.com"
        )
        group = factories.Group(
            authority_provided_id="something_else", authority="example.com"
        )
        group_service.fetch.return_value = pre_existing_group

        with pytest.raises(HTTPConflict, match="group with groupid.*already exists"):
            views.update(group, pyramid_request)
Beispiel #12
0
    def test_it_creates_group_context_from_updated_group(
            self, pyramid_request, context, group_update_service,
            GroupJSONPresenter):
        group_update_service.update.return_value = context.group

        result = views.update(context, pyramid_request)

        GroupJSONPresenter.assert_called_with(context.group, pyramid_request)
        GroupJSONPresenter.return_value.asdict.assert_called_once_with(
            expand=["organization", "scopes"])
        assert result == GroupJSONPresenter.return_value.asdict.return_value
Beispiel #13
0
    def test_it_inits_group_update_schema(
        self, pyramid_request, group, UpdateGroupAPISchema
    ):
        views.update(group, pyramid_request)

        UpdateGroupAPISchema.return_value.validate.assert_called_once_with({})
Beispiel #14
0
    def test_it_does_not_raise_HTTPConflict_if_duplicate_is_same_group(
            self, pyramid_request, UpdateGroupAPISchema, context,
            group_service):
        group_service.fetch.return_value = context.group

        views.update(context, pyramid_request)
Beispiel #15
0
    def test_it_inits_group_update_schema(
        self, pyramid_request, group, UpdateGroupAPISchema
    ):
        views.update(group, pyramid_request)

        UpdateGroupAPISchema.return_value.validate.assert_called_once_with({})