Skip to content

Add writer API and tests#13

Open
teferi wants to merge 1 commit intoreader_apifrom
writer_api
Open

Add writer API and tests#13
teferi wants to merge 1 commit intoreader_apifrom
writer_api

Conversation

@teferi
Copy link
Collaborator

@teferi teferi commented Dec 19, 2016

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+17.05%) to 72.683% when pulling 68a426b on writer_api into 4f8a5a6 on reader_api.

@coveralls
Copy link

Coverage Status

Coverage increased (+17.05%) to 72.683% when pulling 156f310 on writer_api into 7e56d45 on reader_api.

return flask.jsonify({"error": "Was unable to save document"}), 500


@bp.route("/<region>/runbooks/<book_id>", methods=["PUT", "DELETE"])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather prefer to have two separate handlers: one for PUT and one for DELETE. Right now it looks like you have one big function which contains only one if ... else ... statement, moreover two clauses of this if share only es and index_name variables.

# NOTE(kzaitsev): jsonschema exception has really good unicode
# error representation
return flask.jsonify(
{"error": u"{}".format(e)}), 400
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This validation (57-64 lines) looks pretty generic and can be re-used in 96-103 lines if will be created as a decorator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is generic, but writing it as a decorator — I believe would only hurt readability. it's only used in PUT branch of the 2d endpoint, so this decorator would need to somehow handle that. Looks like more code to me

@teferi teferi force-pushed the reader_api branch 3 times, most recently from 47f5c38 to f31f7b4 Compare December 26, 2016 13:44
@coveralls
Copy link

Coverage Status

Coverage increased (+12.5%) to 66.426% when pulling 323ff03 on writer_api into f31f7b4 on reader_api.

@coveralls
Copy link

Coverage Status

Coverage increased (+12.4%) to 66.547% when pulling 9d9e3a9 on writer_api into 54dd4db on reader_api.

@coveralls
Copy link

Coverage Status

Coverage increased (+12.4%) to 66.547% when pulling 9d9e3a9 on writer_api into 54dd4db on reader_api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants