Remove re-setting ordered_components hotfix; bump ereuse-utils
This commit is contained in:
parent
d2160b9db5
commit
bf8a943883
|
@ -85,12 +85,6 @@ class SnapshotView(View):
|
||||||
|
|
||||||
db.session.add(snapshot)
|
db.session.add(snapshot)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
# todo we are setting snapshot dirty again with this components but
|
|
||||||
# we do not want to update it.
|
|
||||||
# The real solution is https://stackoverflow.com/questions/
|
|
||||||
# 24480581/set-the-insert-order-of-a-many-to-many-sqlalchemy-
|
|
||||||
# flask-app-sqlite-db?noredirect=1&lq=1
|
|
||||||
snapshot.components = ordered_components
|
|
||||||
ret = self.schema.jsonify(snapshot) # transform it back
|
ret = self.schema.jsonify(snapshot) # transform it back
|
||||||
ret.status_code = 201
|
ret.status_code = 201
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -5,7 +5,7 @@ click==6.7
|
||||||
click-spinner==0.1.8
|
click-spinner==0.1.8
|
||||||
colorama==0.3.9
|
colorama==0.3.9
|
||||||
colour==0.1.5
|
colour==0.1.5
|
||||||
ereuse-utils[naming, test, session, cli]==0.4.0b15
|
ereuse-utils[naming, test, session, cli]==0.4.0b18
|
||||||
Flask==1.0.2
|
Flask==1.0.2
|
||||||
Flask-Cors==3.0.6
|
Flask-Cors==3.0.6
|
||||||
Flask-SQLAlchemy==2.3.2
|
Flask-SQLAlchemy==2.3.2
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -32,7 +32,7 @@ setup(
|
||||||
'teal>=0.2.0a35', # teal always first
|
'teal>=0.2.0a35', # teal always first
|
||||||
'click',
|
'click',
|
||||||
'click-spinner',
|
'click-spinner',
|
||||||
'ereuse-utils[naming, test, session, cli]>=0.4b15',
|
'ereuse-utils[naming, test, session, cli]>=0.4b18',
|
||||||
'hashids',
|
'hashids',
|
||||||
'marshmallow_enum',
|
'marshmallow_enum',
|
||||||
'psycopg2-binary',
|
'psycopg2-binary',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
from operator import itemgetter
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
@ -79,13 +80,17 @@ def test_snapshot_post(user: UserClient):
|
||||||
assert 'events' not in snapshot['device']
|
assert 'events' not in snapshot['device']
|
||||||
assert 'author' not in snapshot['device']
|
assert 'author' not in snapshot['device']
|
||||||
device, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
device, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
||||||
|
key = itemgetter('serialNumber')
|
||||||
|
snapshot['components'].sort(key=key)
|
||||||
|
device['components'].sort(key=key)
|
||||||
assert snapshot['components'] == device['components']
|
assert snapshot['components'] == device['components']
|
||||||
|
|
||||||
assert tuple(c['type'] for c in snapshot['components']) == (m.GraphicCard.t, m.RamModule.t,
|
assert {c['type'] for c in snapshot['components']} == {m.GraphicCard.t, m.RamModule.t,
|
||||||
m.Processor.t)
|
m.Processor.t}
|
||||||
rate = next(e for e in snapshot['events'] if e['type'] == WorkbenchRate.t)
|
rate = next(e for e in snapshot['events'] if e['type'] == WorkbenchRate.t)
|
||||||
rate, _ = user.get(res=Event, item=rate['id'])
|
rate, _ = user.get(res=Event, item=rate['id'])
|
||||||
assert rate['device']['id'] == snapshot['device']['id']
|
assert rate['device']['id'] == snapshot['device']['id']
|
||||||
|
rate['components'].sort(key=key)
|
||||||
assert rate['components'] == snapshot['components']
|
assert rate['components'] == snapshot['components']
|
||||||
assert rate['snapshot']['id'] == snapshot['id']
|
assert rate['snapshot']['id'] == snapshot['id']
|
||||||
|
|
||||||
|
@ -390,6 +395,9 @@ def assert_similar_components(components1: List[dict], components2: List[dict]):
|
||||||
similar than the components in components2.
|
similar than the components in components2.
|
||||||
"""
|
"""
|
||||||
assert len(components1) == len(components2)
|
assert len(components1) == len(components2)
|
||||||
|
key = itemgetter('serialNumber')
|
||||||
|
components1.sort(key=key)
|
||||||
|
components2.sort(key=key)
|
||||||
for c1, c2 in zip(components1, components2):
|
for c1, c2 in zip(components1, components2):
|
||||||
assert_similar_device(c1, c2)
|
assert_similar_device(c1, c2)
|
||||||
|
|
||||||
|
|
Reference in New Issue