Merge branch 'testing' into feature/document-erased
This commit is contained in:
commit
0d033e94d4
|
@ -6,12 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
ml).
|
||||
|
||||
## master
|
||||
[1.0.6-beta]
|
||||
|
||||
## testing
|
||||
[1.0.7-beta]
|
||||
|
||||
## testing
|
||||
[1.0.8-beta]
|
||||
|
||||
## [1.0.7-beta]
|
||||
- [addend] #158 support for encrypted snapshots data
|
||||
- [addend] #135 adding trade system
|
||||
- [addend] #140 adding endpoint for download the settings for usb workbench
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = "1.0.7-beta"
|
||||
__version__ = "1.0.8-beta"
|
||||
|
|
|
@ -539,7 +539,6 @@ class ConfirmDocument(ActionWithMultipleDocuments):
|
|||
"""If there are one device than have one confirmation,
|
||||
then remove the list this device of the list of devices of this action
|
||||
"""
|
||||
# import pdb; pdb.set_trace()
|
||||
if data['documents'] == OrderedSet():
|
||||
return
|
||||
|
||||
|
@ -567,7 +566,6 @@ class RevokeDocument(ActionWithMultipleDocuments):
|
|||
This is not checked in the view becouse the list of documents is inmutable
|
||||
|
||||
"""
|
||||
# import pdb; pdb.set_trace()
|
||||
if data['documents'] == OrderedSet():
|
||||
return
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ class SnapshotView():
|
|||
# snapshot, and we want to wait to flush snapshot at the end
|
||||
|
||||
def __init__(self, snapshot_json: dict, resource_def, schema):
|
||||
# import pdb; pdb.set_trace()
|
||||
self.schema = schema
|
||||
self.resource_def = resource_def
|
||||
self.tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
|
|
|
@ -227,7 +227,6 @@ class RevokeView(ConfirmMixin):
|
|||
|
||||
ids = {d.id for d in data['devices']}
|
||||
lot = data['action'].lot
|
||||
# import pdb; pdb.set_trace()
|
||||
self.model = delete_from_trade(lot, ids)
|
||||
|
||||
|
||||
|
@ -284,7 +283,6 @@ class ConfirmDocumentMixin():
|
|||
Model = None
|
||||
|
||||
def __init__(self, data, resource_def, schema):
|
||||
# import pdb; pdb.set_trace()
|
||||
self.schema = schema
|
||||
a = resource_def.schema.load(data)
|
||||
self.validate(a)
|
||||
|
|
|
@ -197,10 +197,15 @@ class ActionView(View):
|
|||
snapshot = SnapshotView(json, resource_def, self.schema)
|
||||
return snapshot.post()
|
||||
|
||||
if not 'data' in json:
|
||||
txt = 'Invalid snapshot'
|
||||
raise ValidationError(txt)
|
||||
# TODO @cayop uncomment at four weeks
|
||||
# if not 'data' in json:
|
||||
# txt = 'Invalid snapshot'
|
||||
# raise ValidationError(txt)
|
||||
|
||||
# snapshot_data = decode_snapshot(json)
|
||||
|
||||
snapshot_data = json
|
||||
if 'data' in json:
|
||||
snapshot_data = decode_snapshot(json)
|
||||
|
||||
if not snapshot_data:
|
||||
|
@ -245,7 +250,6 @@ class ActionView(View):
|
|||
confirm_revoke = trade_view.ConfirmRevokeDocumentView(json, resource_def, self.schema)
|
||||
return confirm_revoke.post()
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
a = resource_def.schema.load(json)
|
||||
Model = db.Model._decl_class_registry.data[json['type']]()
|
||||
action = Model(**a)
|
||||
|
|
|
@ -224,7 +224,6 @@ class LotDeviceView(LotBaseChildrenView):
|
|||
id = ma.fields.List(ma.fields.Integer())
|
||||
|
||||
def _post(self, lot: Lot, ids: Set[int]):
|
||||
# import pdb; pdb.set_trace()
|
||||
# get only new devices
|
||||
ids -= {x.id for x in lot.devices}
|
||||
if not ids:
|
||||
|
@ -249,7 +248,6 @@ class LotDeviceView(LotBaseChildrenView):
|
|||
if lot.trade:
|
||||
return delete_from_trade(lot, ids)
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
if not g.user == lot.owner:
|
||||
txt = 'This is not your lot'
|
||||
raise ma.ValidationError(txt)
|
||||
|
@ -267,7 +265,6 @@ def delete_from_trade(lot: Lot, ids: Set[int]):
|
|||
txt = 'This is not your trade'
|
||||
raise ma.ValidationError(txt)
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
devices = set(Device.query.filter(Device.id.in_(ids)).filter(
|
||||
Device.owner_id.in_(users)))
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import os
|
|||
import time
|
||||
from datetime import datetime
|
||||
from flask import current_app as app, request, g, Response
|
||||
from marshmallow import ValidationError
|
||||
from teal.resource import View
|
||||
|
||||
from ereuse_devicehub.db import db
|
||||
|
@ -19,7 +20,11 @@ class TradeDocumentView(View):
|
|||
def post(self):
|
||||
"""Add one document."""
|
||||
|
||||
try:
|
||||
data = request.get_json(validate=True)
|
||||
except ValueError as err:
|
||||
raise ValidationError(err)
|
||||
|
||||
hash3 = data['file_hash']
|
||||
db_hash = ReportHash(hash3=hash3)
|
||||
db.session.add(db_hash)
|
||||
|
|
|
@ -293,7 +293,6 @@ def test_live(user: UserClient, client: Client, app: Devicehub):
|
|||
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||
def test_live_example(user: UserClient, client: Client, app: Devicehub):
|
||||
"""Tests inserting a Live into the database and GETting it."""
|
||||
# import pdb; pdb.set_trace()
|
||||
acer = file('snapshotLive')
|
||||
snapshot, _ = user.post(acer, res=models.Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
|
@ -1244,7 +1243,6 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
|
|||
res=Lot,
|
||||
item='{}/devices'.format(lot['id']),
|
||||
query=devices[-1:], status=200)
|
||||
# import pdb; pdb.set_trace()
|
||||
assert len(trade.lot.devices) == len(trade.devices) == 10
|
||||
assert device_10.actions[-1].t == 'Revoke'
|
||||
|
||||
|
@ -1302,7 +1300,6 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
|
|||
snap10['device']['id']
|
||||
]
|
||||
}
|
||||
# import pdb; pdb.set_trace()
|
||||
user2.post(res=models.Action, data=request_reconfirm)
|
||||
assert device_10.actions[-1].t == 'Confirm'
|
||||
assert device_10.actions[-1].user == trade.user_from
|
||||
|
@ -1680,7 +1677,6 @@ def test_trade_case4(user: UserClient, user2: UserClient):
|
|||
# Normal revoke
|
||||
user2.post(res=models.Action, data=request_revoke)
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
assert device1.actions[-2].t == 'Trade'
|
||||
assert device1.actions[-1].t == 'Confirm'
|
||||
assert device1.actions[-1].user == trade.user_to
|
||||
|
@ -2222,7 +2218,6 @@ def test_trade_case12(user: UserClient, user2: UserClient):
|
|||
|
||||
user.post(res=models.Action, data=request_post)
|
||||
trade = models.Trade.query.one()
|
||||
# import pdb; pdb.set_trace()
|
||||
|
||||
device1, device = trade.devices
|
||||
|
||||
|
@ -2296,7 +2291,6 @@ def test_trade_case13(user: UserClient, user2: UserClient):
|
|||
|
||||
user.post(res=models.Action, data=request_post)
|
||||
trade = models.Trade.query.one()
|
||||
# import pdb; pdb.set_trace()
|
||||
|
||||
lot, _ = user2.post({},
|
||||
res=Lot,
|
||||
|
@ -2370,7 +2364,6 @@ def test_trade_case14(user: UserClient, user2: UserClient):
|
|||
|
||||
user.post(res=models.Action, data=request_post)
|
||||
trade = models.Trade.query.one()
|
||||
# import pdb; pdb.set_trace()
|
||||
|
||||
lot, _ = user2.post({},
|
||||
res=Lot,
|
||||
|
|
|
@ -112,7 +112,6 @@ def test_snapshot_post(user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_same_device_tow_users(user: UserClient, user2: UserClient):
|
||||
"""Two users can up the same snapshot and the system save 2 computers"""
|
||||
# import pdb; pdb.set_trace()
|
||||
user.post(file('basic.snapshot'), res=Snapshot)
|
||||
i, _ = user.get(res=m.Device)
|
||||
pc = next(d for d in i['items'] if d['type'] == 'Desktop')
|
||||
|
|
Reference in New Issue