예제 #1
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_validates_the_posted_data(self, pyramid_request,
                                          create_schema):
        """It should call validate() with a request.json_body."""
        views.create(pyramid_request)

        create_schema.return_value.validate.assert_called_once_with(
            pyramid_request.json_body)
예제 #2
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_raises_if_validate_raises(self, pyramid_request, create_schema):
        create_schema.return_value.validate.side_effect = ValidationError('asplode')

        with pytest.raises(ValidationError) as exc:
            views.create(pyramid_request)

        assert exc.value.message == 'asplode'
예제 #3
0
    def test_it_raises_if_validate_raises(self, pyramid_request, create_schema):
        create_schema.return_value.validate.side_effect = ValidationError('asplode')

        with pytest.raises(ValidationError) as exc:
            views.create(pyramid_request)

        assert str(exc.value) == 'asplode'
예제 #4
0
    def test_it_presents_annotation(self,
                                    annotation_resource,
                                    presentation_service,
                                    pyramid_request):
        views.create(pyramid_request)

        presentation_service.present.assert_called_once_with(
                annotation_resource.return_value)
예제 #5
0
파일: api_test.py 프로젝트: st-fresh/h
    def test_it_raises_if_validate_raises(self, pyramid_request, schemas):
        schemas.CreateAnnotationSchema.return_value.validate.side_effect = (
            ValidationError('asplode'))

        with pytest.raises(ValidationError) as exc:
            views.create(pyramid_request)

        assert exc.value.message == 'asplode'
예제 #6
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_raises_if_create_annotation_raises(self, pyramid_request,
                                                   storage):
        storage.create_annotation.side_effect = ValidationError('asplode')

        with pytest.raises(ValidationError) as exc:
            views.create(pyramid_request)

        assert exc.value.message == 'asplode'
예제 #7
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_creates_the_annotation_in_storage(self, pyramid_request,
                                                  storage, create_schema,
                                                  group_service):
        schema = create_schema.return_value

        views.create(pyramid_request)

        storage.create_annotation.assert_called_once_with(
            pyramid_request, schema.validate.return_value, group_service)
예제 #8
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_raises_if_create_annotation_raises(self,
                                                   pyramid_request,
                                                   storage):
        storage.create_annotation.side_effect = ValidationError('asplode')

        with pytest.raises(ValidationError) as exc:
            views.create(pyramid_request)

        assert exc.value.message == 'asplode'
예제 #9
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.create(pyramid_request)
예제 #10
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.create(pyramid_request)
예제 #11
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_publishes_annotation_event(self, AnnotationEvent,
                                           pyramid_request, storage):
        """It publishes an annotation "create" event for the annotation."""
        views.create(pyramid_request)

        annotation = storage.create_annotation.return_value

        AnnotationEvent.assert_called_once_with(pyramid_request, annotation.id,
                                                'create')
        pyramid_request.notify_after_commit.assert_called_once_with(
            AnnotationEvent.return_value)
예제 #12
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_creates_the_annotation_in_storage(self,
                                                  pyramid_request,
                                                  storage,
                                                  create_schema,
                                                  group_service):
        schema = create_schema.return_value

        views.create(pyramid_request)

        storage.create_annotation.assert_called_once_with(
            pyramid_request, schema.validate.return_value, group_service)
예제 #13
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_initialises_annotation_resource(self, storage,
                                                annotation_resource,
                                                pyramid_request, group_service,
                                                links_service):

        annotation = storage.create_annotation.return_value

        views.create(pyramid_request)

        annotation_resource.assert_called_once_with(annotation, group_service,
                                                    links_service)
예제 #14
0
파일: api_test.py 프로젝트: st-fresh/h
    def test_it_inits_AnnotationJSONPresenter(self, AnnotationJSONPresenter,
                                              annotation_resource,
                                              links_service, group_service,
                                              pyramid_request, storage):
        views.create(pyramid_request)

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

        AnnotationJSONPresenter.assert_called_once_with(
            annotation_resource.return_value)
예제 #15
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_inits_AnnotationJSONPresenter(self,
                                              AnnotationJSONPresenter,
                                              annotation_resource,
                                              links_service,
                                              group_service,
                                              pyramid_request,
                                              storage):
        views.create(pyramid_request)

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

        AnnotationJSONPresenter.assert_called_once_with(annotation_resource.return_value)
예제 #16
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_publishes_annotation_event(self,
                                           AnnotationEvent,
                                           pyramid_request,
                                           storage):
        """It publishes an annotation "create" event for the annotation."""
        views.create(pyramid_request)

        annotation = storage.create_annotation.return_value

        AnnotationEvent.assert_called_once_with(pyramid_request,
                                                annotation.id,
                                                'create')
        pyramid_request.notify_after_commit.assert_called_once_with(
            AnnotationEvent.return_value)
예제 #17
0
파일: api_test.py 프로젝트: st-fresh/h
    def test_it_returns_presented_annotation(self, AnnotationJSONPresenter,
                                             pyramid_request):
        result = views.create(pyramid_request)

        AnnotationJSONPresenter.return_value.asdict.assert_called_once_with()
        assert result == (
            AnnotationJSONPresenter.return_value.asdict.return_value)
예제 #18
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_returns_presented_annotation(self,
                                             AnnotationJSONPresenter,
                                             pyramid_request):
        result = views.create(pyramid_request)

        AnnotationJSONPresenter.return_value.asdict.assert_called_once_with()
        assert result == (
            AnnotationJSONPresenter.return_value.asdict.return_value)
예제 #19
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_returns_presented_annotation(self, presentation_service,
                                             pyramid_request):
        result = views.create(pyramid_request)

        assert result == presentation_service.present.return_value
예제 #20
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_validates_the_posted_data(self, pyramid_request, create_schema):
        """It should call validate() with a request.json_body."""
        views.create(pyramid_request)

        create_schema.return_value.validate.assert_called_once_with(pyramid_request.json_body)
예제 #21
0
파일: api_test.py 프로젝트: st-fresh/h
    def test_it_validates_the_posted_data(self, pyramid_request, schemas):
        """It should call validate() with a request.json_body."""
        views.create(pyramid_request)

        schemas.CreateAnnotationSchema.return_value.validate\
            .assert_called_once_with(pyramid_request.json_body)
예제 #22
0
파일: api_test.py 프로젝트: truthadjustr/h
    def test_it_inits_CreateAnnotationSchema(self, pyramid_request,
                                             create_schema):
        views.create(pyramid_request)

        create_schema.assert_called_once_with(pyramid_request)
예제 #23
0
파일: api_test.py 프로젝트: gnott/h
    def test_it_inits_CreateAnnotationSchema(self, pyramid_request, create_schema):
        views.create(pyramid_request)

        create_schema.assert_called_once_with(pyramid_request)