-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_queries.py
50 lines (42 loc) · 1.6 KB
/
test_queries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# SPDX-FileCopyrightText: 2023 Magenta ApS <https://magenta.dk>
# SPDX-License-Identifier: MPL-2.0
import datetime
from unittest.mock import AsyncMock
from uuid import uuid4
import pytest
from job_function_configurator.autogenerated_graphql_client import GraphQLClient
@pytest.mark.asyncio
async def test_mo_get_engagement_method():
"""
Tests if the MO client execute coroutine for get_engagement was
awaited, and if it was awaited with the arguments we expect.
"""
mocked_mo_client = GraphQLClient()
mocked_mo_client.get_engagement = AsyncMock()
engagement_uuid = uuid4()
email_user_key = ["foo", "bar"]
await mocked_mo_client.get_engagement(engagement_uuid, email_user_key)
# ASSERT
mocked_mo_client.get_engagement.assert_awaited_once()
mocked_mo_client.get_engagement.assert_awaited_once_with(
engagement_uuid, email_user_key
)
@pytest.mark.asyncio
async def test_mo_update_extension_field():
"""
Tests if the MO client execute coroutine for get_engagement was
awaited, and if it was awaited with the arguments we expect.
"""
mocked_mo_client = GraphQLClient()
mocked_mo_client.update_extension_field = AsyncMock()
engagement_uuid = uuid4()
from_date = datetime.date.today()
update_to_extension = "foo"
await mocked_mo_client.update_extension_field(
engagement_uuid, from_date, update_to_extension
)
# ASSERT
mocked_mo_client.update_extension_field.assert_awaited_once()
mocked_mo_client.update_extension_field.assert_awaited_once_with(
engagement_uuid, from_date, update_to_extension
)