Move Microsoft face fixture to integration test (#112993)

* Move Microsoft face fixture to integration test

* Update tests/components/microsoft_face/test_init.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Fix

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Joost Lekkerkerker 2024-03-11 04:26:37 +01:00 committed by GitHub
parent db44efc1a3
commit a78e389d9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 112 additions and 19 deletions

View File

@ -134,15 +134,15 @@ async def test_setup_component_test_entities(
"""Set up component."""
aioclient_mock.get(
ENDPOINT_URL.format("persongroups"),
text=load_fixture("microsoft_face_persongroups.json"),
text=load_fixture("persongroups.json", "microsoft_face"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group1/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group2/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face"),
)
with assert_setup_component(3, mf.DOMAIN):
@ -202,15 +202,15 @@ async def test_service_person(
"""Set up component, test person services."""
aioclient_mock.get(
ENDPOINT_URL.format("persongroups"),
text=load_fixture("microsoft_face_persongroups.json"),
text=load_fixture("persongroups.json", "microsoft_face"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group1/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group2/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face"),
)
with assert_setup_component(3, mf.DOMAIN):
@ -220,7 +220,7 @@ async def test_service_person(
aioclient_mock.post(
ENDPOINT_URL.format("persongroups/test_group1/persons"),
text=load_fixture("microsoft_face_create_person.json"),
text=load_fixture("create_person.json", "microsoft_face"),
)
aioclient_mock.delete(
ENDPOINT_URL.format(
@ -274,15 +274,15 @@ async def test_service_face(
"""Set up component, test person face services."""
aioclient_mock.get(
ENDPOINT_URL.format("persongroups"),
text=load_fixture("microsoft_face_persongroups.json"),
text=load_fixture("persongroups.json", "microsoft_face"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group1/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group2/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face"),
)
CONFIG["camera"] = {"platform": "demo"}

View File

@ -0,0 +1,12 @@
[
{
"personGroupId": "test_group1",
"name": "test group1",
"userData": "test"
},
{
"personGroupId": "test_group2",
"name": "test group2",
"userData": "test"
}
]

View File

@ -0,0 +1,21 @@
[
{
"personId": "25985303-c537-4467-b41d-bdb45cd95ca1",
"name": "Ryan",
"userData": "User-provided data attached to the person",
"persistedFaceIds": [
"015839fb-fbd9-4f79-ace9-7675fc2f1dd9",
"fce92aed-d578-4d2e-8114-068f8af4492e",
"b64d5e15-8257-4af2-b20a-5a750f8940e7"
]
},
{
"personId": "2ae4935b-9659-44c3-977f-61fac20d0538",
"name": "David",
"userData": "User-provided data attached to the person",
"persistedFaceIds": [
"30ea1073-cc9e-4652-b1e3-d08fb7b95315",
"fbd2a038-dbff-452c-8e79-2ee81b1aa84e"
]
}
]

View File

@ -97,15 +97,15 @@ async def test_ms_detect_process_image(
"""Set up and scan a picture and test plates from event."""
aioclient_mock.get(
ENDPOINT_URL.format("persongroups"),
text=load_fixture("microsoft_face_persongroups.json"),
text=load_fixture("persongroups.json", "microsoft_face_detect"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group1/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face_detect"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group2/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face_detect"),
)
await async_setup_component(hass, ip.DOMAIN, CONFIG)
@ -127,7 +127,7 @@ async def test_ms_detect_process_image(
aioclient_mock.post(
ENDPOINT_URL.format("detect"),
text=load_fixture("microsoft_face_detect.json"),
text=load_fixture("detect.json", "microsoft_face_detect"),
params={"returnFaceAttributes": "age,gender"},
)

View File

@ -0,0 +1,27 @@
[
{
"faceId": "c5c24a82-6845-4031-9d5d-978df9175426",
"faceRectangle": {
"width": 78,
"height": 78,
"left": 394,
"top": 54
},
"faceAttributes": {
"age": 71.0,
"gender": "male",
"smile": 0.88,
"facialHair": {
"mustache": 0.8,
"beard": 0.1,
"sideburns": 0.02
},
"glasses": "sunglasses",
"headPose": {
"roll": 2.1,
"yaw": 3,
"pitch": 0
}
}
}
]

View File

@ -0,0 +1,12 @@
[
{
"personGroupId": "test_group1",
"name": "test group1",
"userData": "test"
},
{
"personGroupId": "test_group2",
"name": "test group2",
"userData": "test"
}
]

View File

@ -0,0 +1,21 @@
[
{
"personId": "25985303-c537-4467-b41d-bdb45cd95ca1",
"name": "Ryan",
"userData": "User-provided data attached to the person",
"persistedFaceIds": [
"015839fb-fbd9-4f79-ace9-7675fc2f1dd9",
"fce92aed-d578-4d2e-8114-068f8af4492e",
"b64d5e15-8257-4af2-b20a-5a750f8940e7"
]
},
{
"personId": "2ae4935b-9659-44c3-977f-61fac20d0538",
"name": "David",
"userData": "User-provided data attached to the person",
"persistedFaceIds": [
"30ea1073-cc9e-4652-b1e3-d08fb7b95315",
"fbd2a038-dbff-452c-8e79-2ee81b1aa84e"
]
}
]

View File

@ -99,15 +99,15 @@ async def test_ms_identify_process_image(
"""Set up and scan a picture and test plates from event."""
aioclient_mock.get(
ENDPOINT_URL.format("persongroups"),
text=load_fixture("microsoft_face_persongroups.json"),
text=load_fixture("persongroups.json", "microsoft_face_identify"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group1/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face_identify"),
)
aioclient_mock.get(
ENDPOINT_URL.format("persongroups/test_group2/persons"),
text=load_fixture("microsoft_face_persons.json"),
text=load_fixture("persons.json", "microsoft_face_identify"),
)
await async_setup_component(hass, ip.DOMAIN, CONFIG)
@ -129,11 +129,11 @@ async def test_ms_identify_process_image(
aioclient_mock.post(
ENDPOINT_URL.format("detect"),
text=load_fixture("microsoft_face_detect.json"),
text=load_fixture("detect.json", "microsoft_face_identify"),
)
aioclient_mock.post(
ENDPOINT_URL.format("identify"),
text=load_fixture("microsoft_face_identify.json"),
text=load_fixture("identify.json", "microsoft_face_identify"),
)
common.async_scan(hass, entity_id="image_processing.test_local")