chassis not required
This commit is contained in:
parent
b1c141e02b
commit
aef220a5dc
|
@ -101,7 +101,7 @@ class Computer(Device):
|
|||
collection_class=OrderedSet,
|
||||
description='The components that are inside this computer.')
|
||||
chassis = EnumField(enums.ComputerChassis,
|
||||
required=False,
|
||||
required=True,
|
||||
description=m.Computer.chassis.comment)
|
||||
ram_size = Integer(dump_only=True,
|
||||
data_key='ramSize',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from contextlib import suppress
|
||||
from enum import Enum, IntEnum, unique
|
||||
from enum import Enum, IntEnum, unique, EnumMeta
|
||||
from typing import Set, Union
|
||||
|
||||
import inflection
|
||||
|
@ -207,9 +207,20 @@ class DisplayTech(Enum):
|
|||
return self.name
|
||||
|
||||
|
||||
class DefaultEnumMeta(EnumMeta):
|
||||
default = object()
|
||||
|
||||
def __call__(cls, value=default, *args, **kwargs):
|
||||
# import pdb; pdb.set_trace()
|
||||
if value is DefaultEnumMeta.default:
|
||||
# Assume the first enum is default
|
||||
return next(iter(cls))
|
||||
return super().__call__(value, *args, **kwargs)
|
||||
|
||||
@unique
|
||||
class ComputerChassis(Enum):
|
||||
class ComputerChassis(Enum, metaclass=DefaultEnumMeta):
|
||||
"""The chassis of a computer."""
|
||||
Nothing = None
|
||||
Tower = 'Tower'
|
||||
Docking = 'Docking'
|
||||
AllInOne = 'All in one'
|
||||
|
|
|
@ -679,22 +679,15 @@ def test_snapshot_failed_missing_hdd_benchmark(app: Devicehub, user: UserClient)
|
|||
|
||||
|
||||
@pytest.mark.mvp
|
||||
def test_snapshot_failed_null_chassis(app: Devicehub, user: UserClient):
|
||||
def test_snapshot_not_failed_null_chassis(app: Devicehub, user: UserClient):
|
||||
""" This test check if the file snapshot is create when some snapshot is wrong """
|
||||
tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors')
|
||||
snapshot_error = file('failed.snapshot.422.null-chassis')
|
||||
snapshot_error = file('desktop-9644w8n-lenovo-0169622.snapshot')
|
||||
snapshot_error['device']['chassis'] = 'Nothing'
|
||||
uuid = snapshot_error['uuid']
|
||||
|
||||
snapshot = {'software': '', 'version': '', 'uuid': ''}
|
||||
with pytest.raises(TypeError):
|
||||
user.post(res=Snapshot, data=snapshot_error)
|
||||
|
||||
files = [x for x in os.listdir(path_dir_base) if uuid in x]
|
||||
if files:
|
||||
path_snapshot = os.path.join(path_dir_base, files[0])
|
||||
with open(path_snapshot) as file_snapshot:
|
||||
snapshot = json.loads(file_snapshot.read())
|
||||
snapshot, res = user.post(res=Snapshot, data=snapshot_error)
|
||||
|
||||
shutil.rmtree(tmp_snapshots)
|
||||
|
||||
|
|
Reference in New Issue