Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add one more test for invalid package insertion #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def ingest_to_graph():
response = {'message': report.get('message'),
'epv': input_json,
'count_imported_EPVs': report.get('count_imported_EPVs')}
print(response)
# TODO the previous code can raise a runtime exception, does not we need to handle that?
if report.get('status') is not 'Success':
return flask.jsonify(response), 500
Expand Down
21 changes: 21 additions & 0 deletions test/test_insertion_from_minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@ def test_insertion_not_exists():
logger.error("Traceback for latest failure in import call: %s" % tb)


def test_insertion_invalid():
"""Test if the stored e/p/v data can be retrieved back."""
list_epv = [
{
"version": "0.0.0",
"name": "INVALID",
"ecosystem": "INVALID"
}
]

# if True: # with pytest.raises(RuntimeError):
try:
Copy link
Member

Choose a reason for hiding this comment

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

why not to use pytest.raises referenced in the comment?

report = import_epv_from_s3_http(list_epv, select_doc=['not_exists_data'])
logger.info(report)
assert report['status'] == "Success"
assert report["count_imported_EPVs"] == 0
except RuntimeError:
tb = traceback.format_exc()
logger.error("Traceback for latest failure in import call: %s" % tb)


if __name__ == '__main__':
test_insertion()
test_create_minio_bucket()