mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
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:
parent
db44efc1a3
commit
a78e389d9b
@ -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"}
|
||||
|
@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"personGroupId": "test_group1",
|
||||
"name": "test group1",
|
||||
"userData": "test"
|
||||
},
|
||||
{
|
||||
"personGroupId": "test_group2",
|
||||
"name": "test group2",
|
||||
"userData": "test"
|
||||
}
|
||||
]
|
21
tests/components/microsoft_face_detect/fixtures/persons.json
Normal file
21
tests/components/microsoft_face_detect/fixtures/persons.json
Normal 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"
|
||||
]
|
||||
}
|
||||
]
|
@ -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"},
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"personGroupId": "test_group1",
|
||||
"name": "test group1",
|
||||
"userData": "test"
|
||||
},
|
||||
{
|
||||
"personGroupId": "test_group2",
|
||||
"name": "test group2",
|
||||
"userData": "test"
|
||||
}
|
||||
]
|
@ -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"
|
||||
]
|
||||
}
|
||||
]
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user