Skip to content

Commit

Permalink
Rest APi added for importing a complete report. (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan committed Dec 10, 2019
1 parent 3f6bbbe commit d5f1be5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/server/src/routes/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def post_reports_attribute(reports_attribute: str, database: Database):


@bottle.post("/api/v1/report/import")
def post_reports_attribute(database: Database):
def post_report_import(database: Database):
"""Set a reports overview attribute."""
value = dict(bottle.request.json)
return import_json_report(database, value)
Expand Down
13 changes: 12 additions & 1 deletion components/server/tests/routes/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from routes.report import (
delete_metric, delete_report, delete_source, delete_subject, export_report_as_pdf, get_metrics, get_reports,
get_tag_report, post_metric_attribute, post_metric_new, post_new_subject, post_report_attribute, post_report_new,
post_reports_attribute, post_source_attribute, post_source_new, post_source_parameter, post_subject_attribute
post_reports_attribute, post_source_attribute, post_source_new, post_source_parameter, post_subject_attribute,
post_report_import
)
from server_utilities.functions import iso_timestamp
from server_utilities.type import MetricId, ReportId, SourceId, SubjectId
Expand Down Expand Up @@ -707,6 +708,16 @@ def test_post_reports_attribute_layout(self, request):
inserted = self.database.reports_overviews.insert.call_args_list[0][0][0]
self.assertEqual("Jenny changed the layout of the reports overview.", inserted["delta"]["description"])

@patch("bottle.request")
def test_post_report_import(self, request):
"""Test that a report is imported correctly."""
#self.database.reports_overviews.find_one.return_value = dict(_id="id", title="Reports")
request.json = dict(_id="id", title="QT", report_uuid="qt", subjects={})
post_report_import(self.database)
inserted = self.database.reports.insert.call_args_list[0][0][0]
self.assertEqual("QT", inserted["title"])
self.assertEqual("qt", inserted["report_uuid"])

@patch("bottle.request")
def test_get_tag_report(self, request):
"""Test that a tag report can be retrieved."""
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

- If you have a [Gravatar](https://gravatar.com), it will be shown next to your username after you log in.
- Rest APi added for importing a complete report. Closes [#818](https://github.com/ICTU/quality-time/issues/818).

### Changed

Expand Down

0 comments on commit d5f1be5

Please sign in to comment.