From 14a27a3d85d9f375900d79f3a2e14d20aadf2401 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 21 Jan 2021 17:13:36 +0100 Subject: [PATCH] bug fix change smallint for integer --- ...ef_change_testdatastorage_smallint_for_.py | 36 +++++++++++++++++++ ereuse_devicehub/resources/action/models.py | 4 +-- .../asus-eee-1000h.snapshot.bug1857.yaml | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 ereuse_devicehub/migrations/versions/0cbd839b09ef_change_testdatastorage_smallint_for_.py diff --git a/ereuse_devicehub/migrations/versions/0cbd839b09ef_change_testdatastorage_smallint_for_.py b/ereuse_devicehub/migrations/versions/0cbd839b09ef_change_testdatastorage_smallint_for_.py new file mode 100644 index 00000000..12346873 --- /dev/null +++ b/ereuse_devicehub/migrations/versions/0cbd839b09ef_change_testdatastorage_smallint_for_.py @@ -0,0 +1,36 @@ +"""change TestDataStorage SmallInt for Integer + +Revision ID: 0cbd839b09ef +Revises: b4bd1538bad5 +Create Date: 2021-01-21 12:53:21.996221 + +""" +from alembic import context +from alembic import op +import sqlalchemy as sa +import sqlalchemy_utils +import citext +import teal + + +# revision identifiers, used by Alembic. +revision = '0cbd839b09ef' +down_revision = 'b4bd1538bad5' +branch_labels = None +depends_on = None + + +def get_inv(): + INV = context.get_x_argument(as_dictionary=True).get('inventory') + if not INV: + raise ValueError("Inventory value is not specified") + return INV + +def upgrade(): + op.alter_column('test_data_storage', 'current_pending_sector_count', type_=sa.Integer(), schema=f'{get_inv()}') + op.alter_column('test_data_storage', 'offline_uncorrectable', type_=sa.Integer(), schema=f'{get_inv()}') + + +def downgrade(): + op.alter_column('test_data_storage', 'current_pending_sector_count', type_=sa.SmallInteger(), schema=f'{get_inv()}') + op.alter_column('test_data_storage', 'offline_uncorrectable', type_=sa.SmallInteger(), schema=f'{get_inv()}') diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index 6d7832ab..e34d579a 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -742,8 +742,8 @@ class TestDataStorage(TestMixin, Test): power_cycle_count = Column(SmallInteger) _reported_uncorrectable_errors = Column('reported_uncorrectable_errors', Integer) command_timeout = Column(Integer) - current_pending_sector_count = Column(SmallInteger) - offline_uncorrectable = Column(SmallInteger) + current_pending_sector_count = Column(Integer) + offline_uncorrectable = Column(Integer) remaining_lifetime_percentage = Column(SmallInteger) elapsed = Column(Interval, nullable=False) diff --git a/tests/files/asus-eee-1000h.snapshot.bug1857.yaml b/tests/files/asus-eee-1000h.snapshot.bug1857.yaml index d1df932c..79fb1d45 100644 --- a/tests/files/asus-eee-1000h.snapshot.bug1857.yaml +++ b/tests/files/asus-eee-1000h.snapshot.bug1857.yaml @@ -21,7 +21,7 @@ ], "manufacturer": "ASUSTeK Computer INC." }, - "uuid": "d1b70cb8-8929-4f36-99b7-fe052cec0abd", + "uuid": "d1b70cb8-8929-4f36-99b7-fe052cec0ab1", "components": [ { "serialNumber": "00:24:8c:7f:cf:2d",