fixing event device

This commit is contained in:
Cayo Puigdefabregas 2021-10-22 21:14:10 +02:00
parent 6091f31c17
commit 9faa1697a7
2 changed files with 10 additions and 16 deletions

View file

@ -36,16 +36,10 @@ from ereuse_devicehub.resources.device.metrics import Metrics
def create_code(context):
# import pdb; pdb.set_trace()
_id = Device.query.order_by(Device.id.desc()).first() or 3
if not _id == 3:
_id = _id.id + 1
code = hashcode.encode(_id)
# from ereuse_devicehub.resources.tag.model import Tag
# tag = Tag(device_id=_id, id=code)
# db.session.add(tag)
return code
return hashcode.encode(_id)
class Device(Thing):
@ -1183,4 +1177,4 @@ def create_code_tag(mapper, connection, device):
from flask_sqlalchemy import event
event.listen(Device, 'after_update', create_code_tag, propagate=True)
event.listen(Device, 'after_insert', create_code_tag, propagate=True)

View file

@ -260,10 +260,10 @@ def test_generic_action(action_model_state: Tuple[models.Action, states.Trading]
@pytest.mark.parametrize('action_model',
(pytest.param(ams, id=ams.__class__.__name__)
for ams in [
models.Recycling,
models.Use,
models.Refurbish,
models.Management
models.Recycling,
models.Use,
models.Refurbish,
models.Management
]))
def test_simple_status_actions(action_model: models.Action, user: UserClient, user2: UserClient):
"""Simple test of status action."""
@ -281,10 +281,10 @@ def test_simple_status_actions(action_model: models.Action, user: UserClient, us
@pytest.mark.parametrize('action_model',
(pytest.param(ams, id=ams.__class__.__name__)
for ams in [
models.Recycling,
models.Use,
models.Refurbish,
models.Management
models.Recycling,
models.Use,
models.Refurbish,
models.Management
]))
def test_outgoinlot_status_actions(action_model: models.Action, user: UserClient, user2: UserClient):
"""Test of status actions in outgoinlot."""