Sort events by default using end_time
This commit is contained in:
parent
58be2162f7
commit
0dc8ced255
|
@ -121,5 +121,5 @@
|
|||
],
|
||||
"version": "11.0a4",
|
||||
"elapsed": 6,
|
||||
"endTime": "2016-11-03T17:17:17.266543"
|
||||
"endTime": "2016-11-03T17:17:17.266543+00:00"
|
||||
}
|
||||
|
|
|
@ -92,15 +92,15 @@
|
|||
{
|
||||
"severity": "Info",
|
||||
"type": "StepRandom",
|
||||
"startTime": "2018-07-11T11:20:01.005336",
|
||||
"endTime": "2018-07-11T11:42:12.971177"
|
||||
"startTime": "2018-07-11T11:20:01.005336+00:00",
|
||||
"endTime": "2018-07-11T11:42:12.971177+00:00"
|
||||
}
|
||||
],
|
||||
|
||||
"severity": "Info",
|
||||
"type": "EraseBasic",
|
||||
"endTime": "2018-07-11T11:42:12.975358",
|
||||
"startTime": "2018-07-11T11:20:01.004892"
|
||||
"endTime": "2018-07-11T11:42:12.975358+00:00",
|
||||
"startTime": "2018-07-11T11:20:01.004892+00:00"
|
||||
},
|
||||
{
|
||||
"writeSpeed": 26.6,
|
||||
|
@ -151,7 +151,7 @@
|
|||
"version": "11.0a3",
|
||||
"closed": false,
|
||||
"elapsed": 1512,
|
||||
"endTime": "2018-07-11T11:17:00.888231",
|
||||
"endTime": "2018-07-11T11:17:00.888231+00:00",
|
||||
"type": "Snapshot",
|
||||
"expectedEvents": [
|
||||
"Benchmark",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"closed": false,
|
||||
"elapsed": -3058,
|
||||
"uuid": "106930cd-e948-4cca-a8c8-1e39d6192ad6",
|
||||
"endTime": "2018-07-11T10:47:50.822380",
|
||||
"endTime": "2018-07-11T10:47:50.822380+00:00",
|
||||
"components": [
|
||||
{
|
||||
"type": "Processor",
|
||||
|
@ -73,15 +73,15 @@
|
|||
{
|
||||
"type": "EraseBasic",
|
||||
|
||||
"endTime": "2018-07-11T11:56:52.390306",
|
||||
"endTime": "2018-07-11T11:56:52.390306+00:00",
|
||||
"severity": "Info",
|
||||
"startTime": "2018-07-11T10:49:31.998217",
|
||||
"startTime": "2018-07-11T10:49:31.998217+00:00",
|
||||
"steps": [
|
||||
{
|
||||
"type": "StepRandom",
|
||||
"endTime": "2018-07-11T11:56:52.386505",
|
||||
"endTime": "2018-07-11T11:56:52.386505+00:00",
|
||||
"severity": "Info",
|
||||
"startTime": "2018-07-11T10:49:31.998609"
|
||||
"startTime": "2018-07-11T10:49:31.998609+00:00"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -80,17 +80,17 @@
|
|||
"readSpeed": 77.7
|
||||
},
|
||||
{
|
||||
"startTime": "2018-07-11T10:32:14.445306",
|
||||
"startTime": "2018-07-11T10:32:14.445306+00:00",
|
||||
|
||||
"type": "EraseBasic",
|
||||
"severity": "Info",
|
||||
"endTime": "2018-07-11T10:53:46.442123",
|
||||
"endTime": "2018-07-11T10:53:46.442123+00:00",
|
||||
"steps": [
|
||||
{
|
||||
"startTime": "2018-07-11T10:32:14.445496",
|
||||
"startTime": "2018-07-11T10:32:14.445496+00:00",
|
||||
"type": "StepRandom",
|
||||
"severity": "Info",
|
||||
"endTime": "2018-07-11T10:53:46.438901"
|
||||
"endTime": "2018-07-11T10:53:46.438901+00:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -112,17 +112,17 @@
|
|||
"length": "Short"
|
||||
},
|
||||
{
|
||||
"startTime": "2018-07-11T10:53:46.442187",
|
||||
"startTime": "2018-07-11T10:53:46.442187+00:00",
|
||||
|
||||
"type": "EraseBasic",
|
||||
"severity": "Info",
|
||||
"endTime": "2018-07-11T11:16:28.469899",
|
||||
"endTime": "2018-07-11T11:16:28.469899+00:00",
|
||||
"steps": [
|
||||
{
|
||||
"startTime": "2018-07-11T10:53:46.442343",
|
||||
"startTime": "2018-07-11T10:53:46.442343+00:00",
|
||||
"type": "StepRandom",
|
||||
"severity": "Info",
|
||||
"endTime": "2018-07-11T11:16:28.463789"
|
||||
"endTime": "2018-07-11T11:16:28.463789+00:00"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -175,6 +175,6 @@
|
|||
"EraseBasic"
|
||||
],
|
||||
"software": "Workbench",
|
||||
"endTime": "2018-07-11T10:30:22.395958",
|
||||
"endTime": "2018-07-11T10:30:22.395958+00:00",
|
||||
"elapsed": 2766
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"uuid": "9c3560a9-371c-4392-b586-37090b5f79c6",
|
||||
"version": "11.0a3",
|
||||
"closed": false,
|
||||
"endTime": "2018-07-11T13:26:29.365504",
|
||||
"endTime": "2018-07-11T13:26:29.365504+00:00",
|
||||
"type": "Snapshot",
|
||||
"device": {
|
||||
"serialNumber": "PB357N0",
|
||||
|
@ -99,15 +99,15 @@
|
|||
"status": "Unspecified Error. Self-test not started."
|
||||
},
|
||||
{
|
||||
"startTime": "2018-07-11T13:28:07.319948",
|
||||
"startTime": "2018-07-11T13:28:07.319948+00:00",
|
||||
"type": "EraseBasic",
|
||||
"endTime": "2018-07-11T14:04:04.864425",
|
||||
"endTime": "2018-07-11T14:04:04.864425+00:00",
|
||||
"severity": "Info",
|
||||
"steps": [
|
||||
{
|
||||
"startTime": "2018-07-11T13:28:07.320244",
|
||||
"startTime": "2018-07-11T13:28:07.320244+00:00",
|
||||
"type": "StepRandom",
|
||||
"endTime": "2018-07-11T14:04:04.861590",
|
||||
"endTime": "2018-07-11T14:04:04.861590+00:00",
|
||||
"severity": "Info"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -101,14 +101,14 @@
|
|||
"events": [
|
||||
{
|
||||
"severity": "Info",
|
||||
"endTime": "2018-07-11T11:33:41.531918",
|
||||
"startTime": "2018-07-11T10:30:35.643855",
|
||||
"endTime": "2018-07-11T11:33:41.531918+00:00",
|
||||
"startTime": "2018-07-11T10:30:35.643855+00:00",
|
||||
"type": "EraseBasic",
|
||||
"steps": [
|
||||
{
|
||||
"type": "StepRandom",
|
||||
"endTime": "2018-07-11T11:33:41.529224",
|
||||
"startTime": "2018-07-11T10:30:35.644043",
|
||||
"endTime": "2018-07-11T11:33:41.529224+00:00",
|
||||
"startTime": "2018-07-11T10:30:35.644043+00:00",
|
||||
"severity": "Info"
|
||||
}
|
||||
]
|
||||
|
@ -155,7 +155,7 @@
|
|||
"StressTest",
|
||||
"EraseBasic"
|
||||
],
|
||||
"endTime": "2018-07-11T10:28:55.879745",
|
||||
"endTime": "2018-07-11T10:28:55.879745+00:00",
|
||||
"type": "Snapshot",
|
||||
"elapsed": 3886,
|
||||
"closed": false
|
||||
|
|
|
@ -98,15 +98,15 @@
|
|||
"steps": [
|
||||
{
|
||||
"type": "StepRandom",
|
||||
"startTime": "2018-07-03T09:15:22.257059",
|
||||
"startTime": "2018-07-03T09:15:22.257059+00:00",
|
||||
"severity": "Info",
|
||||
"endTime": "2018-07-03T10:32:11.843190"
|
||||
"endTime": "2018-07-03T10:32:11.843190+00:00"
|
||||
}
|
||||
],
|
||||
"startTime": "2018-07-03T09:15:22.256074",
|
||||
"startTime": "2018-07-03T09:15:22.256074+00:00",
|
||||
"severity": "Info",
|
||||
|
||||
"endTime": "2018-07-03T10:32:11.848455"
|
||||
"endTime": "2018-07-03T10:32:11.848455+00:00"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -133,7 +133,7 @@
|
|||
"version": "11.0a2",
|
||||
"type": "Snapshot",
|
||||
"software": "Workbench",
|
||||
"endTime": "2018-07-03T09:10:57.034598",
|
||||
"endTime": "2018-07-03T09:10:57.034598+00:00",
|
||||
"device": {
|
||||
"type": "Laptop",
|
||||
"model": "1001PXD",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"uuid": "0c822fb7-6e51-4781-86cf-994bd306212e",
|
||||
"software": "Workbench",
|
||||
"closed": false,
|
||||
"endTime": "2018-07-05T11:57:17.284891",
|
||||
"endTime": "2018-07-05T11:57:17.284891+00:00",
|
||||
"components": [
|
||||
{
|
||||
"type": "NetworkAdapter",
|
||||
|
|
|
@ -167,5 +167,5 @@
|
|||
"model": "HP Compaq 8100 Elite SFF"
|
||||
},
|
||||
"type": "Snapshot",
|
||||
"endTime": "2018-06-29T12:28:54.508266"
|
||||
"endTime": "2018-06-29T12:28:54.508266+00:00"
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Benchmark",
|
||||
"StressTest"
|
||||
],
|
||||
"endTime": "2018-06-29T15:29:29.322424",
|
||||
"endTime": "2018-06-29T15:29:29.322424+00:00",
|
||||
"elapsed": 391,
|
||||
"software": "Workbench",
|
||||
"components": [
|
||||
|
|
|
@ -158,7 +158,7 @@
|
|||
"serialNumber": "CZC0408YJG"
|
||||
}
|
||||
],
|
||||
"endTime": "2018-07-11T16:11:43.467824",
|
||||
"endTime": "2018-07-11T16:11:43.467824+00:00",
|
||||
"version": "11.0a3",
|
||||
"software": "Workbench",
|
||||
"type": "Snapshot",
|
||||
|
|
|
@ -44,8 +44,6 @@ class Device(Thing):
|
|||
Devices can contain ``Components``, which are just a type of device
|
||||
(it is a recursive relationship).
|
||||
"""
|
||||
EVENT_SORT_KEY = attrgetter('created')
|
||||
|
||||
id = Column(BigInteger, Sequence('device_seq'), primary_key=True)
|
||||
id.comment = """
|
||||
The identifier of the device for this database. Used only
|
||||
|
@ -150,7 +148,7 @@ class Device(Thing):
|
|||
|
||||
Events are returned by descending ``created`` time.
|
||||
"""
|
||||
return sorted(chain(self.events_multiple, self.events_one), key=self.EVENT_SORT_KEY)
|
||||
return sorted(chain(self.events_multiple, self.events_one))
|
||||
|
||||
@property
|
||||
def problems(self):
|
||||
|
@ -285,8 +283,7 @@ class Device(Thing):
|
|||
raise LookupError('{!r} does not contain events of types {}.'.format(self, types))
|
||||
|
||||
def _warning_events(self, events):
|
||||
return sorted((ev for ev in events if ev.severity >= Severity.Warning),
|
||||
key=self.EVENT_SORT_KEY)
|
||||
return sorted(ev for ev in events if ev.severity >= Severity.Warning)
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.id < other.id
|
||||
|
@ -393,7 +390,7 @@ class Computer(Device):
|
|||
|
||||
@property
|
||||
def events(self) -> list:
|
||||
return sorted(chain(super().events, self.events_parent), key=self.EVENT_SORT_KEY)
|
||||
return sorted(chain(super().events, self.events_parent))
|
||||
|
||||
@property
|
||||
def ram_size(self) -> int:
|
||||
|
@ -565,7 +562,7 @@ class Component(Device):
|
|||
|
||||
@property
|
||||
def events(self) -> list:
|
||||
return sorted(chain(super().events, self.events_components), key=self.EVENT_SORT_KEY)
|
||||
return sorted(chain(super().events, self.events_components))
|
||||
|
||||
|
||||
class JoinedComponentTableMixin:
|
||||
|
|
|
@ -12,7 +12,7 @@ Within the above general classes are subclasses in A order.
|
|||
|
||||
from collections import Iterable
|
||||
from contextlib import suppress
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_UP
|
||||
from typing import Optional, Set, Union
|
||||
from uuid import uuid4
|
||||
|
@ -22,6 +22,7 @@ import teal.db
|
|||
from boltons import urlutils
|
||||
from citext import CIText
|
||||
from flask import current_app as app, g
|
||||
from sortedcontainers import SortedSet
|
||||
from sqlalchemy import BigInteger, Boolean, CheckConstraint, Column, Enum as DBEnum, \
|
||||
Float, ForeignKey, Integer, Interval, JSON, Numeric, SmallInteger, Unicode, event, orm
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
|
@ -55,6 +56,13 @@ class JoinedTableMixin:
|
|||
return Column(UUID(as_uuid=True), ForeignKey(Event.id), primary_key=True)
|
||||
|
||||
|
||||
_sorted_events = {
|
||||
'order_by': lambda: Event.end_time,
|
||||
'collection_class': SortedSet
|
||||
}
|
||||
"""For db.backref, return the events sorted by end_time."""
|
||||
|
||||
|
||||
class Event(Thing):
|
||||
"""Event performed on a device.
|
||||
|
||||
|
@ -100,8 +108,7 @@ class Event(Thing):
|
|||
backref=backref('events',
|
||||
lazy=True,
|
||||
cascade=CASCADE_OWN,
|
||||
order_by=lambda: Event.created,
|
||||
collection_class=OrderedSet),
|
||||
**_sorted_events),
|
||||
primaryjoin='Event.snapshot_id == Snapshot.id')
|
||||
|
||||
author_id = Column(UUID(as_uuid=True),
|
||||
|
@ -126,10 +133,7 @@ class Event(Thing):
|
|||
default=lambda: g.user.individual.id)
|
||||
# todo compute the org
|
||||
agent = relationship(Agent,
|
||||
backref=backref('events_agent',
|
||||
lazy=True,
|
||||
collection_class=OrderedSet,
|
||||
order_by=lambda: Event.created),
|
||||
backref=backref('events_agent', lazy=True, **_sorted_events),
|
||||
primaryjoin=agent_id == Agent.id)
|
||||
agent_id.comment = """
|
||||
The direct performer or driver of the action. e.g. John wrote a book.
|
||||
|
@ -139,10 +143,7 @@ class Event(Thing):
|
|||
"""
|
||||
|
||||
components = relationship(Component,
|
||||
backref=backref('events_components',
|
||||
lazy=True,
|
||||
order_by=lambda: Event.created,
|
||||
collection_class=OrderedSet),
|
||||
backref=backref('events_components', lazy=True, **_sorted_events),
|
||||
secondary=lambda: EventComponent.__table__,
|
||||
order_by=lambda: Component.id,
|
||||
collection_class=OrderedSet)
|
||||
|
@ -161,10 +162,7 @@ class Event(Thing):
|
|||
"""
|
||||
parent_id = Column(BigInteger, ForeignKey(Computer.id))
|
||||
parent = relationship(Computer,
|
||||
backref=backref('events_parent',
|
||||
lazy=True,
|
||||
order_by=lambda: Event.created,
|
||||
collection_class=OrderedSet),
|
||||
backref=backref('events_parent', lazy=True, **_sorted_events),
|
||||
primaryjoin=parent_id == Computer.id)
|
||||
parent_id.comment = """
|
||||
For events that are performed to components, the device parent
|
||||
|
@ -227,7 +225,18 @@ class Event(Thing):
|
|||
|
||||
@property
|
||||
def date_str(self):
|
||||
return '{:%c}'.format(self.end_time or self.created)
|
||||
return '{:%c}'.format(self.end_time)
|
||||
|
||||
def __init__(self, **kwargs) -> None:
|
||||
# sortedset forces us to do this before calling our parent init
|
||||
self.end_time = kwargs.get('end_time', None)
|
||||
if not self.end_time:
|
||||
# Set default for end_time, make it the same of created
|
||||
kwargs['created'] = self.end_time = datetime.now(timezone.utc)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.end_time < other.end_time
|
||||
|
||||
def __str__(self) -> str:
|
||||
return '{}'.format(self.severity)
|
||||
|
@ -254,8 +263,7 @@ class EventWithOneDevice(JoinedTableMixin, Event):
|
|||
backref=backref('events_one',
|
||||
lazy=True,
|
||||
cascade=CASCADE_OWN,
|
||||
order_by=lambda: EventWithOneDevice.created,
|
||||
collection_class=OrderedSet),
|
||||
**_sorted_events),
|
||||
primaryjoin=Device.id == device_id)
|
||||
|
||||
__table_args__ = (
|
||||
|
@ -282,10 +290,7 @@ class EventWithOneDevice(JoinedTableMixin, Event):
|
|||
|
||||
class EventWithMultipleDevices(Event):
|
||||
devices = relationship(Device,
|
||||
backref=backref('events_multiple',
|
||||
lazy=True,
|
||||
order_by=lambda: EventWithMultipleDevices.created,
|
||||
collection_class=OrderedSet),
|
||||
backref=backref('events_multiple', lazy=True, **_sorted_events),
|
||||
secondary=lambda: EventDevice.__table__,
|
||||
order_by=lambda: Device.id,
|
||||
collection_class=OrderedSet)
|
||||
|
@ -1292,10 +1297,7 @@ class Trade(JoinedTableMixin, EventWithMultipleDevices):
|
|||
to_id = Column(UUID(as_uuid=True), ForeignKey(Agent.id), nullable=False)
|
||||
# todo compute the org
|
||||
to = relationship(Agent,
|
||||
backref=backref('events_to',
|
||||
lazy=True,
|
||||
collection_class=OrderedSet,
|
||||
order_by=lambda: Event.created),
|
||||
backref=backref('events_to', lazy=True, **_sorted_events),
|
||||
primaryjoin=to_id == Agent.id)
|
||||
to_comment = """
|
||||
The agent that gets the device due this deal.
|
||||
|
|
|
@ -32,6 +32,7 @@ class Thing(db.Model):
|
|||
"""
|
||||
|
||||
def __init__(self, **kwargs) -> None:
|
||||
# We need to set 'created' before sqlalchemy inits the class
|
||||
# to be able to use sorted containers
|
||||
self.created = kwargs.get('created', datetime.now(timezone.utc))
|
||||
super().__init__(**kwargs)
|
||||
if not self.created:
|
||||
self.created = datetime.now(timezone.utc)
|
||||
|
|
|
@ -31,3 +31,4 @@ sqlalchemy-citext==1.3.post0
|
|||
flask-weasyprint==0.5
|
||||
weasyprint==44
|
||||
psycopg2-binary==2.7.5
|
||||
sortedcontainers==2.1.0
|
||||
|
|
3
setup.py
3
setup.py
|
@ -40,7 +40,8 @@ setup(
|
|||
'requests-toolbelt',
|
||||
'sqlalchemy-citext',
|
||||
'sqlalchemy-utils[password, color, phone]',
|
||||
'Flask-WeasyPrint'
|
||||
'Flask-WeasyPrint',
|
||||
'sortedcontainers'
|
||||
],
|
||||
extras_require={
|
||||
'docs': [
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": true,
|
||||
"endTime": "2018-07-19T15:48:40.635776",
|
||||
"endTime": "2018-07-19T15:48:40.635776+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Dell Inc.",
|
||||
"model": "Latitude E6440",
|
||||
|
|
|
@ -70,19 +70,19 @@
|
|||
"type": "HardDrive",
|
||||
"events": [
|
||||
{
|
||||
"endTime": "2018-07-13T11:54:55.100581",
|
||||
"endTime": "2018-07-13T11:54:55.100581+00:00",
|
||||
"steps": [
|
||||
{
|
||||
"endTime": "2018-07-13T11:54:55.096491",
|
||||
"endTime": "2018-07-13T11:54:55.096491+00:00",
|
||||
"type": "StepRandom",
|
||||
"severity": "Info",
|
||||
"startTime": "2018-07-13T10:52:45.092981"
|
||||
"startTime": "2018-07-13T10:52:45.092981+00:00"
|
||||
}
|
||||
],
|
||||
"type": "EraseBasic",
|
||||
"severity": "Info",
|
||||
|
||||
"startTime": "2018-07-13T10:52:45.092612"
|
||||
"startTime": "2018-07-13T10:52:45.092612+00:00"
|
||||
},
|
||||
{
|
||||
"lifetime": 24658,
|
||||
|
@ -114,18 +114,18 @@
|
|||
"type": "HardDrive",
|
||||
"events": [
|
||||
{
|
||||
"endTime": "2018-07-13T12:55:47.331586",
|
||||
"endTime": "2018-07-13T12:55:47.331586+00:00",
|
||||
"steps": [
|
||||
{
|
||||
"endTime": "2018-07-13T12:55:47.326835",
|
||||
"endTime": "2018-07-13T12:55:47.326835+00:00",
|
||||
"type": "StepRandom",
|
||||
"severity": "Info",
|
||||
"startTime": "2018-07-13T11:54:55.100925"
|
||||
"startTime": "2018-07-13T11:54:55.100925+00:00"
|
||||
}
|
||||
],
|
||||
"type": "EraseBasic",
|
||||
"severity": "Info",
|
||||
"startTime": "2018-07-13T11:54:55.100667"
|
||||
"startTime": "2018-07-13T11:54:55.100667+00:00"
|
||||
},
|
||||
{
|
||||
"lifetime": 21979,
|
||||
|
@ -170,5 +170,5 @@
|
|||
"serialNumber": "109192430003459"
|
||||
}
|
||||
],
|
||||
"endTime": "2018-07-13T10:48:36.738398"
|
||||
"endTime": "2018-07-13T10:48:36.738398+00:00"
|
||||
}
|
||||
|
|
|
@ -123,6 +123,6 @@
|
|||
},
|
||||
"type": "Snapshot",
|
||||
"software": "Workbench",
|
||||
"endTime": "2018-07-19T15:48:40.635776",
|
||||
"endTime": "2018-07-19T15:48:40.635776+00:00",
|
||||
"closed": false
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ type: 'EraseSectors'
|
|||
severity: Info
|
||||
# snapshot: None fulfill!
|
||||
# device: None fulfill!
|
||||
startTime: 2018-01-01T10:10:10
|
||||
endTime: 2018-01-01T12:10:10
|
||||
startTime: '2018-01-01T10:10:10+00:00'
|
||||
endTime: '2018-01-01T12:10:10+00:00'
|
||||
steps:
|
||||
- type: 'StepRandom'
|
||||
startTime: '2018-01-01T10:10:10'
|
||||
endTime: '2018-01-01T12:10:10'
|
||||
- type: 'StepRandom'
|
||||
startTime: '2018-01-01T10:10:10+00:00'
|
||||
endTime: '2018-01-01T12:10:10+00:00'
|
||||
severity: Info
|
||||
|
|
|
@ -157,7 +157,8 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
# p1c2s has two Snapshots, a Remove and an Add
|
||||
p1c2s, _ = user.get(res=m.Device, item=pc2['components'][0]['id'])
|
||||
assert tuple(e['type'] for e in p1c2s['events']) == (
|
||||
'BenchmarkProcessor', 'Snapshot', 'Snapshot', 'Remove')
|
||||
'BenchmarkProcessor', 'Snapshot', 'Snapshot', 'Remove'
|
||||
)
|
||||
|
||||
# We register the first device again, but removing motherboard
|
||||
# and moving processor from the second device to the first.
|
||||
|
@ -304,31 +305,43 @@ def test_snapshot_component_containing_components(user: UserClient):
|
|||
user.post(s, res=Snapshot, status=ValidationError)
|
||||
|
||||
|
||||
def test_erase_privacy_standards(user: UserClient):
|
||||
"""Tests a Snapshot with EraseSectors and the resulting
|
||||
privacy properties.
|
||||
def test_erase_privacy_standards_endtime_sort(user: UserClient):
|
||||
"""Tests a Snapshot with EraseSectors and the resulting privacy
|
||||
properties.
|
||||
|
||||
This tests ensures that only the last erasure is picked up, as
|
||||
erasures have always custom endTime value set.
|
||||
"""
|
||||
s = file('erase-sectors.snapshot')
|
||||
assert '2018-06-01T09:12:06+02:00' == s['components'][0]['events'][0]['endTime']
|
||||
assert s['components'][0]['events'][0]['endTime'] == '2018-06-01T09:12:06+02:00'
|
||||
snapshot = snapshot_and_check(user, s, event_types=(
|
||||
EraseSectors.t,
|
||||
BenchmarkDataStorage.t,
|
||||
BenchmarkProcessor.t
|
||||
))
|
||||
), perform_second_snapshot=False)
|
||||
# Perform a new snapshot changing the erasure time, as if
|
||||
# it is a new erasure performed after.
|
||||
erase = next(e for e in snapshot['events'] if e['type'] == EraseSectors.t)
|
||||
assert '2018-06-01T07:12:06+00:00' == erase['endTime']
|
||||
assert erase['endTime'] == '2018-06-01T07:12:06+00:00'
|
||||
s['uuid'] = uuid4()
|
||||
s['components'][0]['events'][0]['endTime'] = '2018-06-01T07:14:00+00:00'
|
||||
snapshot = snapshot_and_check(user, s, event_types=(
|
||||
EraseSectors.t,
|
||||
BenchmarkDataStorage.t,
|
||||
BenchmarkProcessor.t
|
||||
), perform_second_snapshot=False)
|
||||
|
||||
# The actual test
|
||||
storage = next(e for e in snapshot['components'] if e['type'] == SolidStateDrive.t)
|
||||
storage, _ = user.get(res=m.Device, item=storage['id']) # Let's get storage events too
|
||||
# order: creation time ascending
|
||||
erasure1, benchmark_data_storage1, _snapshot1, erasure2, benchmark_data_storage2, _snapshot2 = \
|
||||
storage['events']
|
||||
# order: endTime ascending
|
||||
# erasure1/2 have an user defined time and others events endTime = created
|
||||
erasure1, erasure2, benchmark_hdd1, _snapshot1, benchmark_hdd2, _snapshot2 = storage['events']
|
||||
assert erasure1['type'] == erasure2['type'] == 'EraseSectors'
|
||||
assert benchmark_data_storage1['type'] == benchmark_data_storage2[
|
||||
'type'] == 'BenchmarkDataStorage'
|
||||
assert benchmark_hdd1['type'] == benchmark_hdd2['type'] == 'BenchmarkDataStorage'
|
||||
assert _snapshot1['type'] == _snapshot2['type'] == 'Snapshot'
|
||||
get_snapshot, _ = user.get(res=Event, item=_snapshot2['id'])
|
||||
assert get_snapshot['events'][0]['endTime'] == '2018-06-01T07:12:06+00:00'
|
||||
# TODO events order are different between snapshots
|
||||
assert get_snapshot['events'][0]['endTime'] == '2018-06-01T07:14:00+00:00'
|
||||
assert snapshot == get_snapshot
|
||||
erasure, _ = user.get(res=Event, item=erasure1['id'])
|
||||
assert len(erasure['steps']) == 2
|
||||
|
|
|
@ -36,7 +36,6 @@ def test_workbench_server_condensed(user: UserClient):
|
|||
snapshot, _ = user.post(res=em.Snapshot, data=s)
|
||||
events = snapshot['events']
|
||||
assert {(event['type'], event['device']) for event in events} == {
|
||||
('RateComputer', 1),
|
||||
('BenchmarkProcessorSysbench', 5),
|
||||
('StressTest', 1),
|
||||
('EraseSectors', 6),
|
||||
|
@ -47,7 +46,8 @@ def test_workbench_server_condensed(user: UserClient):
|
|||
('BenchmarkDataStorage', 6),
|
||||
('BenchmarkDataStorage', 7),
|
||||
('TestDataStorage', 6),
|
||||
('VisualTest', 1)
|
||||
('VisualTest', 1),
|
||||
('RateComputer', 1)
|
||||
}
|
||||
assert snapshot['closed']
|
||||
assert snapshot['severity'] == 'Info'
|
||||
|
@ -63,9 +63,9 @@ def test_workbench_server_condensed(user: UserClient):
|
|||
assert device['rate']['severity'] == 'Info'
|
||||
assert device['rate']['rating'] == 0
|
||||
assert device['rate']['type'] == 'RateComputer'
|
||||
assert device['events'][0]['appearanceRange'] == 'A'
|
||||
assert device['events'][0]['functionalityRange'] == 'B'
|
||||
|
||||
assert device['events'][2]['type'] == 'VisualTest'
|
||||
assert device['events'][2]['appearanceRange'] == 'A'
|
||||
assert device['events'][2]['functionalityRange'] == 'B'
|
||||
assert device['tags'][0]['id'] == 'tag1'
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Acer",
|
||||
"model": "Aspire 5737Z",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "ASUS",
|
||||
"model": "All Series",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "ASUS",
|
||||
"model": "All Series",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": null,
|
||||
"model": null,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": null,
|
||||
"model": null,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "ASUS",
|
||||
"model": "All Series",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Dell Inc.",
|
||||
"model": "Latitude E5530 non-vPro",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": null,
|
||||
"model": null,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "ASUS",
|
||||
"model": "All Series",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "ASUSTeK Computer INC.",
|
||||
"model": "1000H",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Hewlett-Packard",
|
||||
"model": "HP Compaq dc7900 Small Form Factor",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Hewlett-Packard",
|
||||
"model": "HP Compaq 8100 Elite SFF",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Hewlett-Packard",
|
||||
"model": "Pavilion dv4000",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "LENOVO",
|
||||
"model": "7220W3T",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "LENOVO",
|
||||
"model": "7220W3T",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "LENOVO",
|
||||
"model": "3493BAG",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "LENOVO",
|
||||
"model": "7220W3T",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "NEC Computers SAS",
|
||||
"model": "Powermate MLxxx",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": null,
|
||||
"model": null,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Dell Inc.",
|
||||
"model": "OptiPlex 745",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Dell Inc.",
|
||||
"model": "OptiPlex GX520",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Hewlett-Packard",
|
||||
"model": "HP Compaq dc7900 Small Form Factor",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "TOSHIBA",
|
||||
"model": "PORTEGE R700",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "innotek GmbH",
|
||||
"model": "VirtualBox",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "innotek GmbH",
|
||||
"model": "VirtualBox",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "innotek GmbH",
|
||||
"model": "VirtualBox",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Dell Inc.",
|
||||
"model": "Vostro 260",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "LENOVO",
|
||||
"model": "415522G",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "11.0a1",
|
||||
"expectedEvents": [],
|
||||
"closed": false,
|
||||
"endTime": "2000-01-01 00:00:00",
|
||||
"endTime": "2000-01-01 00:00:00+00:00",
|
||||
"device": {
|
||||
"manufacturer": "Timi",
|
||||
"model": "TM1613",
|
||||
|
|
Reference in New Issue