Skip to content

Commit

Permalink
Move Microsoft face fixture to integration test (home-assistant#112993)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
joostlek and balloob authored Mar 11, 2024
1 parent db44efc commit a78e389
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 19 deletions.
File renamed without changes.
20 changes: 10 additions & 10 deletions tests/components/microsoft_face/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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(
Expand Down Expand Up @@ -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"}
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions tests/components/microsoft_face_detect/fixtures/persongroups.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"personGroupId": "test_group1",
"name": "test group1",
"userData": "test"
},
{
"personGroupId": "test_group2",
"name": "test group2",
"userData": "test"
}
]
21 changes: 21 additions & 0 deletions tests/components/microsoft_face_detect/fixtures/persons.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -127,7 +127,7 @@ def mock_face_event(event):

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"},
)

Expand Down
27 changes: 27 additions & 0 deletions tests/components/microsoft_face_identify/fixtures/detect.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"personGroupId": "test_group1",
"name": "test group1",
"userData": "test"
},
{
"personGroupId": "test_group2",
"name": "test group2",
"userData": "test"
}
]
21 changes: 21 additions & 0 deletions tests/components/microsoft_face_identify/fixtures/persons.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -129,11 +129,11 @@ def mock_face_event(event):

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")
Expand Down

0 comments on commit a78e389

Please sign in to comment.