コード例 #1
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_tracks_deprecated_put_requests(self, pyramid_request):
        pyramid_request.method = 'PUT'
        pyramid_request.stats = mock.Mock(spec_set=['incr'])

        views.update(mock.Mock(), pyramid_request)

        pyramid_request.stats.incr.assert_called_once_with('api.deprecated.put_update_annotation')
コード例 #2
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_raises_if_validate_raises(self, pyramid_request,
                                          update_schema):
        update_schema.return_value.validate.side_effect = ValidationError(
            'asplode')

        with pytest.raises(ValidationError):
            views.update(mock.Mock(), pyramid_request)
コード例 #3
0
ファイル: api_test.py プロジェクト: tripti825/hypothesis_own
    def test_it_validates_the_posted_data(self, pyramid_request, update_schema):
        context = mock.Mock()
        schema = update_schema.return_value

        views.update(context, pyramid_request)

        schema.validate.assert_called_once_with(pyramid_request.json_body)
コード例 #4
0
ファイル: api_test.py プロジェクト: tripti825/hypothesis_own
    def test_it_tracks_deprecated_put_requests(self, pyramid_request):
        pyramid_request.method = 'PUT'
        pyramid_request.stats = mock.Mock(spec_set=['incr'])

        views.update(mock.Mock(), pyramid_request)

        pyramid_request.stats.incr.assert_called_once_with('api.deprecated.put_update_annotation')
コード例 #5
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_validates_the_posted_data(self, pyramid_request, update_schema):
        context = mock.Mock()
        schema = update_schema.return_value

        views.update(context, pyramid_request)

        schema.validate.assert_called_once_with(pyramid_request.json_body)
コード例 #6
0
ファイル: api_test.py プロジェクト: tripti825/hypothesis_own
    def test_it_presents_annotation(self,
                                    annotation_resource,
                                    presentation_service,
                                    pyramid_request):
        views.update(mock.Mock(), pyramid_request)

        presentation_service.present.assert_called_once_with(
                annotation_resource.return_value)
コード例 #7
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_inits_the_schema(self, pyramid_request, update_schema):
        context = mock.Mock()

        views.update(context, pyramid_request)

        update_schema.assert_called_once_with(pyramid_request,
                                              context.annotation.target_uri,
                                              context.annotation.groupid)
コード例 #8
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_inits_the_schema(self, pyramid_request, update_schema):
        context = mock.Mock()

        views.update(context, pyramid_request)

        update_schema.assert_called_once_with(pyramid_request,
                                              context.annotation.target_uri,
                                              context.annotation.groupid)
コード例 #9
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_inits_an_AnnotationEvent(self, AnnotationEvent, storage,
                                         pyramid_request):
        context = mock.Mock()

        views.update(context, pyramid_request)

        AnnotationEvent.assert_called_once_with(
            pyramid_request, storage.update_annotation.return_value.id,
            'update')
コード例 #10
0
ファイル: api_test.py プロジェクト: truthadjustr/h
 def test_it_raises_if_json_parsing_fails(self, pyramid_request):
     """It raises PayloadError if parsing of the request body fails."""
     # Make accessing the request.json_body property raise ValueError.
     type(pyramid_request).json_body = {}
     with mock.patch.object(type(pyramid_request),
                            'json_body',
                            new_callable=mock.PropertyMock) as json_body:
         json_body.side_effect = ValueError()
         with pytest.raises(views.PayloadError):
             views.update(mock.Mock(), pyramid_request)
コード例 #11
0
ファイル: api_test.py プロジェクト: gnott/h
 def test_it_raises_if_json_parsing_fails(self, pyramid_request):
     """It raises PayloadError if parsing of the request body fails."""
     # Make accessing the request.json_body property raise ValueError.
     type(pyramid_request).json_body = {}
     with mock.patch.object(type(pyramid_request),
                            'json_body',
                            new_callable=mock.PropertyMock) as json_body:
         json_body.side_effect = ValueError()
         with pytest.raises(views.PayloadError):
             views.update(mock.Mock(), pyramid_request)
コード例 #12
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_initialises_annotation_resource(self, storage,
                                                annotation_resource,
                                                pyramid_request, group_service,
                                                links_service):

        annotation = storage.update_annotation.return_value

        views.update(mock.Mock(), pyramid_request)

        annotation_resource.assert_called_once_with(annotation, group_service,
                                                    links_service)
コード例 #13
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_inits_an_AnnotationEvent(self,
                                         AnnotationEvent,
                                         storage,
                                         pyramid_request):
        context = mock.Mock()

        views.update(context, pyramid_request)

        AnnotationEvent.assert_called_once_with(pyramid_request,
                                                storage.update_annotation.return_value.id,
                                                'update')
コード例 #14
0
ファイル: api_test.py プロジェクト: st-fresh/h
    def test_it_inits_a_presenter(self, AnnotationJSONPresenter,
                                  annotation_resource, group_service,
                                  links_service, pyramid_request, storage):
        views.update(mock.Mock(), pyramid_request)

        annotation_resource.assert_called_once_with(
            storage.update_annotation.return_value, group_service,
            links_service)

        AnnotationJSONPresenter.assert_any_call(
            annotation_resource.return_value)
コード例 #15
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_updates_the_annotation_in_storage(self, pyramid_request,
                                                  storage, update_schema):
        context = mock.Mock()
        schema = update_schema.return_value
        schema.validate.return_value = mock.sentinel.validated_data

        views.update(context, pyramid_request)

        storage.update_annotation.assert_called_once_with(
            pyramid_request.db, context.annotation.id,
            mock.sentinel.validated_data)
コード例 #16
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_inits_a_presenter(self,
                                  AnnotationJSONPresenter,
                                  annotation_resource,
                                  group_service,
                                  links_service,
                                  pyramid_request,
                                  storage):
        views.update(mock.Mock(), pyramid_request)

        annotation_resource.assert_called_once_with(
                storage.update_annotation.return_value, group_service, links_service)

        AnnotationJSONPresenter.assert_any_call(annotation_resource.return_value)
コード例 #17
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_updates_the_annotation_in_storage(self,
                                                  pyramid_request,
                                                  storage,
                                                  update_schema):
        context = mock.Mock()
        schema = update_schema.return_value
        schema.validate.return_value = mock.sentinel.validated_data

        views.update(context, pyramid_request)

        storage.update_annotation.assert_called_once_with(
            pyramid_request.db,
            context.annotation.id,
            mock.sentinel.validated_data
        )
コード例 #18
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_returns_a_presented_dict(self,
                                         AnnotationJSONPresenter,
                                         pyramid_request):
        returned = views.update(mock.Mock(), pyramid_request)

        assert returned == (
            AnnotationJSONPresenter.return_value.asdict.return_value)
コード例 #19
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_fires_the_AnnotationEvent(self, AnnotationEvent,
                                          pyramid_request):
        views.update(mock.Mock(), pyramid_request)

        pyramid_request.notify_after_commit.assert_called_once_with(
            AnnotationEvent.return_value)
コード例 #20
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_raises_if_validate_raises(self, pyramid_request, update_schema):
        update_schema.return_value.validate.side_effect = ValidationError('asplode')

        with pytest.raises(ValidationError):
            views.update(mock.Mock(), pyramid_request)
コード例 #21
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_raises_if_storage_raises(self, pyramid_request, storage):
        storage.update_annotation.side_effect = ValidationError('asplode')

        with pytest.raises(ValidationError):
            views.update(mock.Mock(), pyramid_request)
コード例 #22
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_raises_if_storage_raises(self, pyramid_request, storage):
        storage.update_annotation.side_effect = ValidationError('asplode')

        with pytest.raises(ValidationError):
            views.update(mock.Mock(), pyramid_request)
コード例 #23
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_fires_the_AnnotationEvent(self, AnnotationEvent, pyramid_request):
        views.update(mock.Mock(), pyramid_request)

        pyramid_request.notify_after_commit.assert_called_once_with(
            AnnotationEvent.return_value)
コード例 #24
0
ファイル: api_test.py プロジェクト: gnott/h
    def test_it_dictizes_the_presenter(self,
                                       AnnotationJSONPresenter,
                                       pyramid_request):
        views.update(mock.Mock(), pyramid_request)

        AnnotationJSONPresenter.return_value.asdict.assert_called_with()
コード例 #25
0
ファイル: api_test.py プロジェクト: st-fresh/h
    def test_it_returns_a_presented_dict(self, AnnotationJSONPresenter,
                                         pyramid_request):
        returned = views.update(mock.Mock(), pyramid_request)

        assert returned == (
            AnnotationJSONPresenter.return_value.asdict.return_value)
コード例 #26
0
ファイル: api_test.py プロジェクト: truthadjustr/h
    def test_it_returns_a_presented_dict(self, presentation_service,
                                         pyramid_request):
        returned = views.update(mock.Mock(), pyramid_request)

        assert returned == presentation_service.present.return_value
コード例 #27
0
ファイル: api_test.py プロジェクト: st-fresh/h
    def test_it_dictizes_the_presenter(self, AnnotationJSONPresenter,
                                       pyramid_request):
        views.update(mock.Mock(), pyramid_request)

        AnnotationJSONPresenter.return_value.asdict.assert_called_with()