Skip to content

Commit

Permalink
add CalculateKPIS fixture and replace test 1 with it
Browse files Browse the repository at this point in the history
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
  • Loading branch information
anchit-chandran committed Oct 8, 2024
1 parent bf6544d commit 809fdb4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions project/npda/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pytest_factoryboy import register

# rcpch imports
from project.npda.kpi_class.kpis import CalculateKPIS
from project.npda.tests.factories import (NPDAUserFactory,
OrganisationEmployerFactory,
PaediatricsDiabetesUnitFactory,
Expand All @@ -32,19 +33,30 @@
register(PaediatricsDiabetesUnitFactory) # => npdauser_factory
register(TransferFactory) # => npdauser_factory


@pytest.fixture(autouse=True)
def patch_imd_for_postcode():
"""Automatically patch `imd_for_postcode` for all tests."""
with patch('project.npda.models.patient.imd_for_postcode', return_value=4) as mocked_imd_for_postcode:
with patch(
"project.npda.models.patient.imd_for_postcode", return_value=4
) as mocked_imd_for_postcode:
logger.debug("Patching imd_for_postcode")
yield


@pytest.fixture
def AUDIT_START_DATE():
"""AUDIT_START_DATE is Day 2 of the first audit period"""
return date(year=2024, month=4, day=1)


@pytest.fixture
def AUDIT_END_DATE():
"""AUDIT_END_DATE"""
return date(year=2025, month=3, day=31)
return date(year=2025, month=3, day=31)


@pytest.fixture
def CALCULATE_KPIS_OBJECT_AUDIT_START(AUDIT_START_DATE):
"""Calculate KPIS object initialised with the audit start date"""
return CalculateKPIS(pz_codes=["PZ130"], calculation_date=AUDIT_START_DATE)

0 comments on commit 809fdb4

Please sign in to comment.