import pytest from secretsanta.service import participants2url pytestmark = pytest.mark.anyio async def test_create_group_service(create_group_service, group, config): participants = await create_group_service.run(group) assert ( participants2url( participants=group.participants, group_uuid=group.uuid, server_url=config.server_url, ) == participants ) @pytest.mark.usefixtures("repo_with_data") async def test_create_group_service_returns_existing_group(create_group_service, group, config, group_factory): new_group = group_factory.build() new_group.uuid = group.uuid assert new_group != group participants = await create_group_service.run(new_group) assert ( participants2url( participants=group.participants, group_uuid=group.uuid, server_url=config.server_url, ) == participants ) @pytest.mark.usefixtures("repo_with_data") async def test_get_participants(get_participants_service, group, config): participants = await get_participants_service.run(group.uuid) assert ( participants2url( participants=group.participants, group_uuid=group.uuid, server_url=config.server_url, ) == participants ) async def test_get_participants_returns_none(get_participants_service, group): assert not await get_participants_service.run(group.uuid) @pytest.mark.usefixtures("repo_with_data") async def test_get_pair(get_pair_service, group): assert group.pairs for gifter, giftee in group.pairs.items(): pair = await get_pair_service.run(group.uuid, gifter) assert pair == giftee