Merge remote-tracking branch 'origin/deliverynote' into mvp

# Conflicts:
#	ereuse_devicehub/resources/lot/views.py
This commit is contained in:
nad 2020-03-03 12:26:24 +01:00
commit f9d73653c7
13 changed files with 209 additions and 8 deletions

View File

@ -1377,6 +1377,10 @@ class Trade(JoinedTableMixin, ActionWithMultipleDevices):
"""
class InitTransfer(Trade):
"""The act of transfer ownership of devices between two agents"""
class Sell(Trade):
"""The act of taking money from a buyer in exchange of a device."""

View File

@ -493,6 +493,10 @@ class Trade(ActionWithMultipleDevices):
self.confirms = ... # type: Organize
class InitTransfer(Trade):
pass
class Sell(Trade):
pass

View File

@ -397,6 +397,10 @@ class Trade(ActionWithMultipleDevices):
confirms = NestedOn(Organize)
class InitTransfer(Trade):
__doc__ = m.InitTransfer.__doc__
class Sell(Trade):
__doc__ = m.Sell.__doc__

View File

@ -8,7 +8,8 @@ from teal.marshmallow import ValidationError
from teal.resource import View
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.action.models import Action, RateComputer, Snapshot, VisualTest
from ereuse_devicehub.resources.action.models import Action, RateComputer, Snapshot, VisualTest, \
InitTransfer
from ereuse_devicehub.resources.action.rate.v1_0 import CannotRate
from ereuse_devicehub.resources.device.models import Component, Computer
from ereuse_devicehub.resources.enums import SnapshotSoftware
@ -31,6 +32,8 @@ class ActionView(View):
if json['type'] == VisualTest.t:
pass
# TODO JN add compute rate with new visual test and old components device
if json['type'] == InitTransfer.t:
return self.transfer_ownership()
Model = db.Model._decl_class_registry.data[json['type']]()
action = Model(**a)
db.session.add(action)
@ -101,3 +104,7 @@ class ActionView(View):
ret.status_code = 201
db.session.commit()
return ret
def transfer_ownership(self):
"""Perform a InitTransfer action to change author_id of device"""
pass

View File

@ -95,8 +95,7 @@ class Device(Thing):
color.comment = """The predominant color of the device."""
production_date = Column(db.DateTime)
production_date.comment = """The date of production of the device.
This is timezone naive, as Workbench cannot report this data
with timezone information.
This is timezone naive, as Workbench cannot report this data with timezone information.
"""
variant = Column(db.CIText())
variant.comment = """A variant or sub-model of the device."""

View File

@ -11,7 +11,7 @@
<link rel="stylesheet"
type="text/css"
href="{{ url_for('Document.static', filename='print.css') }}">
<title>Devicehub | {{ title }}</title>
<title>USOdy | {{ title }}</title>
</head>
<body>
<div class="container">

View File

@ -110,6 +110,3 @@ BEGIN
END
$$
LANGUAGE plpgsql;

View File

@ -26,6 +26,7 @@ class Lot(Thing):
description.comment = """A comment about the lot."""
closed = db.Column(db.Boolean, default=False, nullable=False)
closed.comment = """A closed lot cannot be modified anymore."""
devices = db.relationship(Device,
backref=db.backref('lots', lazy=True, collection_class=set),
secondary=lambda: LotDevice.__table__,

View File

@ -88,6 +88,18 @@ class Path:
self.path = ... # type: Ltree
self.created = ... # type: datetime
@classmethod
def has_lot(cls, id, id1):
pass
@classmethod
def delete(cls, id, id1):
pass
@classmethod
def add(cls, id, id1):
pass
class LotDeviceDescendants(db.Model):
device_id = ... # type: Column

View File

@ -129,6 +129,18 @@ class LotView(View):
if path:
cls._p(node['nodes'], path)
def get_lot_deposit(self, l: Lot):
"""Return lot deposit value"""
return l.deposit
def change_state(self):
"""Change state of Lot"""
pass
def transfer_ownership_lot(self):
"""Perform a InitTransfer action to change author_id of lot"""
pass
class LotBaseChildrenView(View):
"""Base class for adding / removing children devices and

View File

@ -0,0 +1,151 @@
---
components:
- size: 10.030411318500475
technology: LCD
resolutionWidth: 1024
model: AUO LCD Monitor
actions: []
type: Display
refreshRate: 60
productionDate: '2009-01-04T00:00:00'
manufacturer: AUO "AUO"
serialNumber:
resolutionHeight: 600
- generation:
actions:
- rate: 164.4981
type: BenchmarkProcessorSysbench
elapsed: 165
- rate: 6650.48
type: BenchmarkProcessor
elapsed: 0
speed: 1
cores: 1
model: Intel Atom CPU N450 @ 1.66GHz
address: 64
type: Processor
threads: 2
manufacturer: Intel Corp.
serialNumber:
brand: Atom
- memory:
model: Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller
actions: []
type: GraphicCard
manufacturer: Intel Corporation
serialNumber:
- size: 2200
technology: LiIon
actions:
- size: 641
type: MeasureBattery
voltage: 12608
cycleCount:
severity: Info
model: AL10A31
type: Battery
manufacturer: SANYO
serialNumber:
- type: SoundCard
actions: []
manufacturer: Intel Corporation
serialNumber:
model: NM10/ICH7 Family High Definition Audio Controller
- type: SoundCard
actions: []
manufacturer: XPA970VW0
serialNumber:
model: 1.3M WebCam
- size: 1024
actions: []
format: SODIMM
model: 48594D503131325336344350362D53362020
interface: DDR2
type: RamModule
manufacturer: Hynix Semiconductor
serialNumber: 4F43487B
speed: 667
- size: 160041.88569599998
variant: 1A01
actions:
- type: EraseBasic
steps:
- type: StepRandom
endTime: '2019-10-23T08:35:31.400587+00:00'
severity: Info
startTime: '2019-10-23T07:49:54.410830+00:00'
endTime: '2019-10-23T08:35:31.400988+00:00'
severity: Info
startTime: '2019-10-23T07:49:54.410193+00:00'
- elapsed: 22
writeSpeed: 17.3
readSpeed: 41.6
type: BenchmarkDataStorage
- status: Completed without error
reallocatedSectorCount: 0
currentPendingSectorCount: 0
assessment: true
severity: Info
offlineUncorrectable: 0
lifetime: 4692
type: TestDataStorage
length: Short
elapsed: 118
powerCycleCount: 5293
model: WDC WD1600BEVT-2
interface: ATA
type: HardDrive
manufacturer: Western Digital
serialNumber: WD-WX11A80W7430
- variant: c1
actions: []
speed: 100
model: AR8152 v1.1 Fast Ethernet
wireless: false
type: NetworkAdapter
serialNumber: 88:ae:1d:a6:f3:d0
manufacturer: Qualcomm Atheros
- variant: '00'
actions: []
speed:
model: Centrino Wireless-N 1000 Condor Peak
wireless: true
type: NetworkAdapter
serialNumber: 00:26:c7:8e:cb:8c
manufacturer: Intel Corporation
- ramMaxSize: 4
slots: 1
model: AOHAPPY
pcmcia: 0
type: Motherboard
version: V3.05(DDR2)
ramSlots: 2
serialNumber: Base Board Serial Number
manufacturer: Acer
serial: 1
actions: []
biosDate: '2010-08-12T00:00:00'
firewire: 0
usb: 5
software: Workbench
device:
sku:
chassis: Netbook
actions:
- type: StressTest
elapsed: 60
severity: Info
- rate: 19.2726
type: BenchmarkRamSysbench
elapsed: 19
model: AOHAPPY
type: Laptop
version: V3.05
manufacturer: Acer
serialNumber: LUSEA0D010038879A01601
uuid: 490fb8c0-81a1-42e9-95e0-5e7db7038ec2
type: Snapshot
version: 11.0b9
endTime: '2019-10-23T07:43:13.625104+00:00'
elapsed: 3138
closed: true

View File

@ -139,6 +139,7 @@ def test_multiple_rates(user: UserClient):
This ensures that rates only takes all the correct actions
and components rates in case device have new tests/benchmarks.
"""
pc = Desktop(chassis=ComputerChassis.Tower)
hdd = HardDrive(size=476940)
hdd.actions_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))

View File

@ -12,7 +12,8 @@ from ereuse_devicehub.client import UserClient
from ereuse_devicehub.db import db
from ereuse_devicehub.devicehub import Devicehub
from ereuse_devicehub.resources.action.models import Action, BenchmarkDataStorage, \
BenchmarkProcessor, EraseSectors, RateComputer, Snapshot, SnapshotRequest, VisualTest
BenchmarkProcessor, EraseSectors, RateComputer, Snapshot, SnapshotRequest, VisualTest, \
MeasureBattery, BenchmarkRamSysbench, StressTest
from ereuse_devicehub.resources.device import models as m
from ereuse_devicehub.resources.device.exceptions import NeedsId
from ereuse_devicehub.resources.device.models import SolidStateDrive
@ -492,3 +493,11 @@ def test_pc_rating_rate_none(user: UserClient):
def test_pc_2(user: UserClient):
s = file('laptop-hp_255_g3_notebook-hewlett-packard-cnd52270fw.snapshot')
snapshot, _ = user.post(res=Snapshot, data=s)
@pytest.mark.xfail(reason='Add battery component assets')
def test_snapshot_pc_with_battery_component(user: UserClient):
pc1 = file('acer.happy.battery.snapshot')
snapshot = snapshot_and_check(user, pc1,
action_types=(StressTest.t, BenchmarkRamSysbench.t),
perform_second_snapshot=False)