diff --git a/ereuse_devicehub/dummy/dummy.py b/ereuse_devicehub/dummy/dummy.py index 5b3fb2bc..5aba1421 100644 --- a/ereuse_devicehub/dummy/dummy.py +++ b/ereuse_devicehub/dummy/dummy.py @@ -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') diff --git a/ereuse_devicehub/resources/enums.py b/ereuse_devicehub/resources/enums.py index 3aed8e6e..1303e0a0 100644 --- a/ereuse_devicehub/resources/enums.py +++ b/ereuse_devicehub/resources/enums.py @@ -109,7 +109,7 @@ class Orientation(Enum): @unique -class TestHardDriveLength(Enum): +class TestDataStorageLength(Enum): Short = 'Short' Extended = 'Extended' diff --git a/ereuse_devicehub/resources/event/models.py b/ereuse_devicehub/resources/event/models.py index c34a78be..650426d2 100644 --- a/ereuse_devicehub/resources/event/models.py +++ b/ereuse_devicehub/resources/event/models.py @@ -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) diff --git a/ereuse_devicehub/resources/event/models.pyi b/ereuse_devicehub/resources/event/models.pyi index db3c3611..a3ca84be 100644 --- a/ereuse_devicehub/resources/event/models.pyi +++ b/ereuse_devicehub/resources/event/models.pyi @@ -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 diff --git a/ereuse_devicehub/resources/event/schemas.py b/ereuse_devicehub/resources/event/schemas.py index 9a143344..7b36998e 100644 --- a/ereuse_devicehub/resources/event/schemas.py +++ b/ereuse_devicehub/resources/event/schemas.py @@ -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() diff --git a/requirements.txt b/requirements.txt index 5934fd5a..074bc613 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index 2bdbb790..7302898f 100644 --- a/setup.py +++ b/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', diff --git a/tests/test_event.py b/tests/test_event.py index a116a148..1a1847fa 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -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) )