basic endpoint for internal stats

This commit is contained in:
Cayo Puigdefabregas 2021-02-19 12:53:42 +01:00
parent 39fcbd24b7
commit ce4dce055d
3 changed files with 26 additions and 0 deletions

View file

@ -252,6 +252,13 @@ class StampsView(View):
return flask.render_template('documents/stamp.html', rq_url=url_path)
class InternalStatsView(View):
def get(self):
result = ''
return jsonify(result)
class DocumentDef(Resource):
__type__ = 'Document'
SCHEMA = None
@ -307,6 +314,9 @@ class DocumentDef(Resource):
stamps_view = StampsView.as_view('StampsView', definition=self, auth=app.auth)
self.add_url_rule('/stamps/', defaults={}, view_func=stamps_view, methods=get)
stamps_view = InternalStatsView.as_view('InternalStatsView', definition=self, auth=app.auth)
self.add_url_rule('/internalstats/', defaults={}, view_func=stamps_view, methods=get)
actions_view = ActionsDocumentView.as_view('ActionsDocumentView',
definition=self,
auth=app.auth)

View file

@ -41,6 +41,7 @@ def test_api_docs(client: Client):
'/documents/erasures/',
'/documents/devices/',
'/documents/stamps/',
'/documents/internalstats/',
'/documents/stock/',
'/documents/check/',
'/documents/lots/',

View file

@ -459,3 +459,18 @@ def test_get_document_lots(user: UserClient, user2: UserClient):
assert export_csv[1][3] == 'comments,lot1,testcomment-lot1,' or 'comments,lot2,testcomment-lot2,'
assert export2_csv[1][1] == 'Lot3-User2'
assert export2_csv[1][3] == 'comments,lot3,testcomment-lot3,'
@pytest.mark.mvp
def test_get_document_internal_stats(user: UserClient):
"""Tests for get teh internal stats."""
# import pdb; pdb.set_trace()
csv_str, _ = user.get(res=documents.DocumentDef.t,
item='internalstats/')
f = StringIO(csv_str)
obj_csv = csv.reader(f, f)
export_csv = list(obj_csv)
assert len(export_csv) == 0