27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
"""The contact card must not present all company equipment as personal hardware."""
|
|
import asyncio
|
|
from unittest.mock import Mock
|
|
|
|
from app.modules.hardware.backend import router
|
|
|
|
|
|
def test_direct_only_excludes_company_equipment(monkeypatch):
|
|
query = Mock(side_effect=[[{'id': 1, 'model': 'Personal PC'}], [{'id': 2, 'model': 'Other employee PC'}]])
|
|
monkeypatch.setattr(router, 'execute_query', query)
|
|
rows = asyncio.run(router.list_hardware_by_contact(1565, direct_only=True))
|
|
assert rows == [{'id': 1, 'model': 'Personal PC'}]
|
|
assert query.call_count == 1
|
|
assert query.call_args.args[1] == (1565,)
|
|
|
|
|
|
def test_no_direct_hardware_stays_empty(monkeypatch):
|
|
monkeypatch.setattr(router, 'execute_query', Mock(return_value=[]))
|
|
assert asyncio.run(router.list_hardware_by_contact(1565, direct_only=True)) == []
|
|
|
|
|
|
def test_existing_case_callers_keep_company_hardware(monkeypatch):
|
|
monkeypatch.setattr(router, 'execute_query', Mock(side_effect=[
|
|
[{'id': 1}], [{'id': 1}, {'id': 2}]
|
|
]))
|
|
assert asyncio.run(router.list_hardware_by_contact(1565)) == [{'id': 1}, {'id': 2}]
|