bugfix test_get_devices

This commit is contained in:
Cayo Puigdefabregas 2020-07-22 12:11:21 +02:00
parent a90b4c9b9d
commit a005d6f597
2 changed files with 11 additions and 9 deletions

View file

@ -391,14 +391,14 @@ def test_sync_execute_register_mismatch_between_tags_and_hid():
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.xfail(reason='It needs to be fixed.')
def test_get_device(app: Devicehub, user: UserClient): def test_get_device(app: Devicehub, user: UserClient):
"""Checks GETting a d.Desktop with its components.""" """Checks GETting a d.Desktop with its components."""
with app.app_context(): with app.app_context():
pc = d.Desktop(model='p1mo', pc = d.Desktop(model='p1mo',
manufacturer='p1ma', manufacturer='p1ma',
serial_number='p1s', serial_number='p1s',
chassis=ComputerChassis.Tower) chassis=ComputerChassis.Tower,
owner_id=user.user['id'])
pc.components = OrderedSet([ pc.components = OrderedSet([
d.NetworkAdapter(model='c1mo', manufacturer='c1ma', serial_number='c1s'), d.NetworkAdapter(model='c1mo', manufacturer='c1ma', serial_number='c1s'),
d.GraphicCard(model='c2mo', manufacturer='c2ma', memory=1500) d.GraphicCard(model='c2mo', manufacturer='c2ma', memory=1500)
@ -428,14 +428,14 @@ def test_get_device(app: Devicehub, user: UserClient):
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.xfail(reason='It needs to be fixed.')
def test_get_devices(app: Devicehub, user: UserClient): def test_get_devices(app: Devicehub, user: UserClient):
"""Checks GETting multiple devices.""" """Checks GETting multiple devices."""
with app.app_context(): with app.app_context():
pc = d.Desktop(model='p1mo', pc = d.Desktop(model='p1mo',
manufacturer='p1ma', manufacturer='p1ma',
serial_number='p1s', serial_number='p1s',
chassis=ComputerChassis.Tower) chassis=ComputerChassis.Tower,
owner_id=user.user['id'])
pc.components = OrderedSet([ pc.components = OrderedSet([
d.NetworkAdapter(model='c1mo', manufacturer='c1ma', serial_number='c1s'), d.NetworkAdapter(model='c1mo', manufacturer='c1ma', serial_number='c1s'),
d.GraphicCard(model='c2mo', manufacturer='c2ma', memory=1500) d.GraphicCard(model='c2mo', manufacturer='c2ma', memory=1500)
@ -443,11 +443,13 @@ def test_get_devices(app: Devicehub, user: UserClient):
pc1 = d.Desktop(model='p2mo', pc1 = d.Desktop(model='p2mo',
manufacturer='p2ma', manufacturer='p2ma',
serial_number='p2s', serial_number='p2s',
chassis=ComputerChassis.Tower) chassis=ComputerChassis.Tower,
owner_id=user.user['id'])
pc2 = d.Laptop(model='p3mo', pc2 = d.Laptop(model='p3mo',
manufacturer='p3ma', manufacturer='p3ma',
serial_number='p3s', serial_number='p3s',
chassis=ComputerChassis.Netbook) chassis=ComputerChassis.Netbook,
owner_id=user.user['id'])
db.session.add_all((pc, pc1, pc2)) db.session.add_all((pc, pc1, pc2))
db.session.commit() db.session.commit()
devices, _ = user.get(res=d.Device) devices, _ = user.get(res=d.Device)

View file

@ -13,7 +13,7 @@ from tests import conftest
try: try:
with db.session.begin_nested(): with db.session.begin_nested():
except Exception as e: except Exception as e:
db.session.commit() db.session.commit()
print(e) print(e)
@ -351,7 +351,6 @@ def test_lot_post_add_children_view_ui_tree_normal(user: UserClient):
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.xfail(reason='It needs to be fixed.')
def test_lot_post_add_remove_device_view(app: Devicehub, user: UserClient): def test_lot_post_add_remove_device_view(app: Devicehub, user: UserClient):
"""Tests adding a device to a lot using POST and """Tests adding a device to a lot using POST and
removing it with DELETE. removing it with DELETE.
@ -361,7 +360,8 @@ def test_lot_post_add_remove_device_view(app: Devicehub, user: UserClient):
device = Desktop(serial_number='foo', device = Desktop(serial_number='foo',
model='bar', model='bar',
manufacturer='foobar', manufacturer='foobar',
chassis=ComputerChassis.Lunchbox) chassis=ComputerChassis.Lunchbox,
owner_id=user.user['id'])
db.session.add(device) db.session.add(device)
db.session.commit() db.session.commit()
device_id = device.id device_id = device.id