Better printing in Dummy; change naming of TestHardDriveLength; bump utils to 0.4b9
This commit is contained in:
parent
a2b9f58bca
commit
a76560d253
|
@ -40,10 +40,10 @@ class Dummy:
|
|||
@click.confirmation_option(prompt='This command (re)creates the DB from scratch.'
|
||||
'Do you want to continue?')
|
||||
def run(self):
|
||||
print('Preparing the database...'.ljust(30), end='')
|
||||
runner = self.app.test_cli_runner()
|
||||
self.app.init_db(erase=True)
|
||||
print('Creating stuff...'.ljust(30), end='')
|
||||
with click_spinner.spinner():
|
||||
self.app.init_db(erase=True)
|
||||
out = runner.invoke(args=['create-org', *self.ORG], catch_exceptions=False).output
|
||||
org_id = json.loads(out)['id']
|
||||
user = self.user_client('user@dhub.com', '1234')
|
||||
|
|
|
@ -109,7 +109,7 @@ class Orientation(Enum):
|
|||
|
||||
|
||||
@unique
|
||||
class TestHardDriveLength(Enum):
|
||||
class TestDataStorageLength(Enum):
|
||||
Short = 'Short'
|
||||
Extended = 'Extended'
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ from ereuse_devicehub.resources.device.models import Component, Computer, DataSt
|
|||
Device, Laptop, Server
|
||||
from ereuse_devicehub.resources.enums import AppearanceRange, BOX_RATE_3, BOX_RATE_5, Bios, \
|
||||
FunctionalityRange, PriceSoftware, RATE_NEGATIVE, RATE_POSITIVE, RatingRange, RatingSoftware, \
|
||||
ReceiverRole, SnapshotExpectedEvents, SnapshotSoftware, TestHardDriveLength
|
||||
ReceiverRole, SnapshotExpectedEvents, SnapshotSoftware, TestDataStorageLength
|
||||
from ereuse_devicehub.resources.image.models import Image
|
||||
from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing
|
||||
from ereuse_devicehub.resources.user.models import User
|
||||
|
@ -595,7 +595,7 @@ class Test(JoinedWithOneDeviceMixin, EventWithOneDevice):
|
|||
|
||||
class TestDataStorage(Test):
|
||||
id = Column(UUID(as_uuid=True), ForeignKey(Test.id), primary_key=True)
|
||||
length = Column(DBEnum(TestHardDriveLength), nullable=False) # todo from type
|
||||
length = Column(DBEnum(TestDataStorageLength), nullable=False) # todo from type
|
||||
status = Column(Unicode(), check_lower('status'), nullable=False)
|
||||
lifetime = Column(Interval)
|
||||
assessment = Column(Boolean)
|
||||
|
|
|
@ -18,7 +18,7 @@ from ereuse_devicehub.resources.agent.models import Agent
|
|||
from ereuse_devicehub.resources.device.models import Component, Computer, Device
|
||||
from ereuse_devicehub.resources.enums import AppearanceRange, Bios, FunctionalityRange, \
|
||||
PriceSoftware, RatingSoftware, ReceiverRole, SnapshotExpectedEvents, SnapshotSoftware, \
|
||||
TestHardDriveLength
|
||||
TestDataStorageLength
|
||||
from ereuse_devicehub.resources.image.models import Image
|
||||
from ereuse_devicehub.resources.models import Thing
|
||||
from ereuse_devicehub.resources.user.models import User
|
||||
|
@ -67,6 +67,7 @@ class Event(Thing):
|
|||
def url(self) -> urlutils.URL:
|
||||
pass
|
||||
|
||||
|
||||
class EventWithOneDevice(Event):
|
||||
|
||||
def __init__(self, id=None, name=None, incidence=None, closed=None, error=None,
|
||||
|
@ -251,7 +252,7 @@ class TestDataStorage(Test):
|
|||
def __init__(self, **kwargs) -> None:
|
||||
super().__init__(**kwargs)
|
||||
self.id = ... # type: UUID
|
||||
self.length = ... # type: TestHardDriveLength
|
||||
self.length = ... # type: TestDataStorageLength
|
||||
self.status = ... # type: str
|
||||
self.lifetime = ... # type: timedelta
|
||||
self.first_error = ... # type: int
|
||||
|
|
|
@ -7,7 +7,7 @@ from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, List,
|
|||
from marshmallow.validate import Length, Range
|
||||
from sqlalchemy.util import OrderedSet
|
||||
from teal.enums import Country, Currency, Subdivision
|
||||
from teal.marshmallow import EnumField, IP, SanitizedStr, Version, URL
|
||||
from teal.marshmallow import EnumField, IP, SanitizedStr, URL, Version
|
||||
from teal.resource import Schema
|
||||
|
||||
from ereuse_devicehub.marshmallow import NestedOn
|
||||
|
@ -15,7 +15,7 @@ from ereuse_devicehub.resources.agent.schemas import Agent
|
|||
from ereuse_devicehub.resources.device.schemas import Component, Computer, Device
|
||||
from ereuse_devicehub.resources.enums import AppearanceRange, Bios, FunctionalityRange, \
|
||||
PriceSoftware, RATE_POSITIVE, RatingSoftware, ReceiverRole, SnapshotExpectedEvents, \
|
||||
SnapshotSoftware, TestHardDriveLength
|
||||
SnapshotSoftware, TestDataStorageLength
|
||||
from ereuse_devicehub.resources.event import models as m
|
||||
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
|
||||
from ereuse_devicehub.resources.schemas import Thing
|
||||
|
@ -267,7 +267,7 @@ class Test(EventWithOneDevice):
|
|||
|
||||
|
||||
class TestDataStorage(Test):
|
||||
length = EnumField(TestHardDriveLength, required=True)
|
||||
length = EnumField(TestDataStorageLength, required=True)
|
||||
status = SanitizedStr(lower=True, validate=Length(max=STR_SIZE), required=True)
|
||||
lifetime = TimeDelta(precision=TimeDelta.DAYS)
|
||||
assessment = Boolean()
|
||||
|
|
|
@ -6,7 +6,7 @@ click-spinner==0.1.8
|
|||
colorama==0.3.9
|
||||
colour==0.1.5
|
||||
ereuse-rate==0.0.2
|
||||
ereuse-utils==0.4.0b8
|
||||
ereuse-utils==0.4.0b9
|
||||
Flask==1.0.2
|
||||
Flask-Cors==3.0.6
|
||||
Flask-SQLAlchemy==2.3.2
|
||||
|
|
2
setup.py
2
setup.py
|
@ -38,7 +38,7 @@ setup(
|
|||
'click',
|
||||
'click-spinner',
|
||||
'ereuse-rate==0.0.2',
|
||||
'ereuse-utils[Naming]>=0.4b8',
|
||||
'ereuse-utils[Naming]>=0.4b9',
|
||||
'hashids',
|
||||
'marshmallow_enum',
|
||||
'psycopg2-binary',
|
||||
|
|
|
@ -10,7 +10,7 @@ from ereuse_devicehub.client import UserClient
|
|||
from ereuse_devicehub.db import db
|
||||
from ereuse_devicehub.resources.device.models import Desktop, Device, GraphicCard, HardDrive, \
|
||||
RamModule, SolidStateDrive
|
||||
from ereuse_devicehub.resources.enums import ComputerChassis, TestHardDriveLength
|
||||
from ereuse_devicehub.resources.enums import ComputerChassis, TestDataStorageLength
|
||||
from ereuse_devicehub.resources.event import models
|
||||
from tests import conftest
|
||||
from tests.conftest import create_user, file
|
||||
|
@ -88,7 +88,7 @@ def test_test_data_storage():
|
|||
device=HardDrive(serial_number='foo', manufacturer='bar', model='foo-bar'),
|
||||
error=False,
|
||||
elapsed=timedelta(minutes=25),
|
||||
length=TestHardDriveLength.Short,
|
||||
length=TestDataStorageLength.Short,
|
||||
status='ok!',
|
||||
lifetime=timedelta(days=120)
|
||||
)
|
||||
|
|
Reference in a new issue