From f398c50288f24f5ef9e7c420f08a04614a7a4075 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 6 Sep 2021 12:44:57 +0200 Subject: [PATCH] clean old code as documents --- .../resources/documents/documents.py | 24 ----------------- .../resources/documents/schemas.py | 20 -------------- tests/test_documents.py | 26 ------------------- 3 files changed, 70 deletions(-) diff --git a/ereuse_devicehub/resources/documents/documents.py b/ereuse_devicehub/resources/documents/documents.py index 50c0162f..f6de8884 100644 --- a/ereuse_devicehub/resources/documents/documents.py +++ b/ereuse_devicehub/resources/documents/documents.py @@ -33,8 +33,6 @@ from ereuse_devicehub.resources.documents.device_row import (DeviceRow, StockRow from ereuse_devicehub.resources.lot import LotView from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.hash_reports import insert_hash, ReportHash, verify_hash -# from ereuse_devicehub.resources.documents.models import RecycleDocument -# from ereuse_devicehub.resources.documents.schemas import RecycleDocument as sh_document class Format(enum.Enum): @@ -291,26 +289,6 @@ class StampsView(View): result=result) -# class RecycleDocumentView(View): -# """ -# This view allow save one document as a proof of one container with some weight was send to recycling. -# """ - -# def post(self): -# # import pdb; pdb.set_trace() -# data = request.get_data() -# schema = sh_document() -# doc = schema.loads(data) -# document = RecycleDocument(**doc) -# db.session.add(document) - -# db.session().final_flush() -# ret = jsonify(document) -# ret.status_code = 201 -# db.session.commit() -# return ret - - class InternalStatsView(DeviceView): @cache(datetime.timedelta(minutes=1)) def find(self, args: dict): @@ -457,5 +435,3 @@ class DocumentDef(Resource): wbconf_view = app.auth.requires_auth(wbconf_view) self.add_url_rule('/wbconf/', view_func=wbconf_view, methods=get) - # recycle_doc_view = RecycleDocumentView.as_view('RecycleDocumentView', definition=self, auth=app.auth) - # self.add_url_rule('/recycle/', defaults={}, view_func=recycle_doc_view, methods={'POST'}) diff --git a/ereuse_devicehub/resources/documents/schemas.py b/ereuse_devicehub/resources/documents/schemas.py index d2302866..d62cec41 100644 --- a/ereuse_devicehub/resources/documents/schemas.py +++ b/ereuse_devicehub/resources/documents/schemas.py @@ -33,23 +33,3 @@ class DataWipeDocument(Thing): @post_load def get_trade_document(self, data): data['document_type'] = 'DataWipeDocument' - - -# class RecycleDocument(Thing): -# __doc__ = m.RecycleDocument.__doc__ -# file_hash = SanitizedStr(data_key='hash', -# default='', -# description=m.RecycleDocument.file_hash.comment, -# validate=validate.Length(max=64)) -# weight = Float(required=False, validate=Range(0.1), description=m.RecycleDocument.weight.comment) -# lot = NestedOn('Lot', only_query='id', description=m.RecycleDocument.lot.__doc__) - -# @post_load -# def get_trade_document(self, data): -# tradedocument = TradeDocument.query.filter_by(file_hash=data['file_hash']).one() -# data['trade_document_id'] = tradedocument.id -# data['file_name'] = tradedocument.file_name -# data['date'] = tradedocument.date -# data['id_document'] = tradedocument.id_document -# data['url'] = tradedocument.url -# data['document_type'] = 'RecycleDocument' diff --git a/tests/test_documents.py b/tests/test_documents.py index 043ebaa5..b18e4c99 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -716,29 +716,3 @@ def test_trade_documents_with_weight(user: UserClient): } doc, _ = user.post(res=TradeDocument, data=request_post) assert doc['weight'] == request_post['weight'] - - -# @pytest.mark.mvp -# @pytest.mark.usefixtures(conftest.app_context.__name__) -# def test_recycle_document(user: UserClient): -# """Tests upload one document""" - -# lotIn, _ = user.post({'name': 'MyLotIn'}, res=Lot) -# lotOut, _ = user.post({'name': 'MyLotOut'}, res=Lot) -# url = 'http://www.ereuse.org/apapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapaaaa', -# request_post = { -# 'filename': 'test.pdf', -# 'hash': 'bbbbbbbb', -# 'url': url, -# 'weight': 15, -# 'lot': lotOut['id'] -# } -# tradedocument, _ = user.post(res=TradeDocument, data=request_post) -# # import pdb; pdb.set_trace() -# request_post2 = { -# 'weight': 15, -# 'hash': tradedocument['hash'], -# 'lot': lotIn['id'] -# } -# doc, _ = user.post(res=documents.DocumentDef.t, item='recycle/', data=request_post2) -# assert doc == request_post['filename']