Make fixture for getting service with organisation

Saves repeatedly defining the same mock.
This commit is contained in:
Chris Hill-Scott
2020-04-02 12:56:47 +01:00
parent 51a5a4b559
commit 0904ac0533
5 changed files with 36 additions and 110 deletions

View File

@@ -2,7 +2,7 @@ import json
import os
from contextlib import contextmanager
from datetime import date, datetime, timedelta
from unittest.mock import Mock
from unittest.mock import Mock, PropertyMock
from uuid import UUID, uuid4
import pytest
@@ -3138,6 +3138,18 @@ def mock_get_no_organisation_by_domain(mocker):
)
@pytest.fixture(scope='function')
def mock_get_service_organisation(
mocker,
mock_get_organisation,
):
return mocker.patch(
'app.models.service.Service.organisation_id',
new_callable=PropertyMock,
return_value=ORGANISATION_ID,
)
@pytest.fixture(scope='function')
def mock_update_service_organisation(mocker):
def _update_service_organisation(service_id, organisation_id):