From f48bbcff804630a729de5008e3daf9fe98862801 Mon Sep 17 00:00:00 2001 From: Sam Dudley Date: Fri, 22 Mar 2024 14:47:07 +0000 Subject: [PATCH] wip --- .../test/test_end_of_month_process.py | 26 +++++++------------ end_of_month/test/test_outturn_variance.py | 14 ++++------ .../test/test_end_of_month_archive_budget.py | 4 +-- .../test_end_of_month_archive_forecast.py | 4 +-- makefile | 2 +- 5 files changed, 19 insertions(+), 31 deletions(-) diff --git a/end_of_month/test/test_end_of_month_process.py b/end_of_month/test/test_end_of_month_process.py index 65d4fbaca..7df159fd4 100644 --- a/end_of_month/test/test_end_of_month_process.py +++ b/end_of_month/test/test_end_of_month_process.py @@ -1,3 +1,4 @@ +import pytest from django.db.models import F from django.test import TestCase @@ -111,18 +112,13 @@ def test_end_of_month_mar(self): self.assertEqual(count, 129) -class ReadArchivedForecastTest(TestCase): - @classmethod - def setUpTestData(cls): - cls.archived_figure = [] - - def setUp(self): +class TestReadArchivedForecastTest: + @pytest.fixture(autouse=True) + def _setup(self): + self.archived_figure = [0 for _ in range(16)] self.init_data = MonthlyFigureSetup() self.init_data.setup_forecast() - for period in range(0, 16): - self.archived_figure.append(0) - def get_period_total(self, period): data_model = forecast_budget_view_model[period] tot_q = data_model.objects.filter( @@ -335,16 +331,12 @@ def test_end_of_month_mar(self): self.assertEqual(budget_total_count, 12) -class ReadArchivedBudgetTest(TestCase): - @classmethod - def setUpTestData(cls): - cls.archived_figure = [] - - def setUp(self): +class TestReadArchivedBudgetTest: + @pytest.fixture(autouse=True) + def _setup(self): + self.archived_figure = [0 for _ in range(16)] self.init_data = MonthlyFigureSetup() self.init_data.setup_budget() - for period in range(0, 16): - self.archived_figure.append(0) def get_period_budget_total(self, period): data_model = forecast_budget_view_model[period] diff --git a/end_of_month/test/test_outturn_variance.py b/end_of_month/test/test_outturn_variance.py index 963553ea3..558503432 100644 --- a/end_of_month/test/test_outturn_variance.py +++ b/end_of_month/test/test_outturn_variance.py @@ -1,21 +1,17 @@ +import pytest from django.db.models import F -from django.test import TestCase from end_of_month.end_of_month_actions import end_of_month_archive from end_of_month.models import forecast_budget_view_model from end_of_month.test.test_utils import MonthlyFigureSetup -class ReadMonthlyVarianceTest(TestCase): - @classmethod - def setUpTestData(cls): - cls.archived_figure = [] - - def setUp(self): +class TestReadMonthlyVarianceTest: + @pytest.fixture(autouse=True) + def _setup(self): + self.archived_figure = [0 for _ in range(16)] self.init_data = MonthlyFigureSetup() self.init_data.setup_forecast() - for period in range(0, 16): - self.archived_figure.append(0) def get_period_total(self, period): data_model = forecast_budget_view_model[period] diff --git a/future_years/test/test_end_of_month_archive_budget.py b/future_years/test/test_end_of_month_archive_budget.py index c083826fe..cd4713bee 100644 --- a/future_years/test/test_end_of_month_archive_budget.py +++ b/future_years/test/test_end_of_month_archive_budget.py @@ -2,12 +2,12 @@ from core.utils.generic_helpers import get_current_financial_year from end_of_month.end_of_month_actions import end_of_month_archive -from end_of_month.test.test_end_of_month_process import ReadArchivedBudgetTest +from end_of_month.test.test_end_of_month_process import TestReadArchivedBudgetTest from end_of_month.test.test_utils import MonthlyFigureSetup from forecast.models import BudgetMonthlyFigure -class ReadArchivedFutureDataForecast(ReadArchivedBudgetTest): +class ReadArchivedFutureDataForecast(TestReadArchivedBudgetTest): def setUp(self): super().setUp() current_year = get_current_financial_year() diff --git a/future_years/test/test_end_of_month_archive_forecast.py b/future_years/test/test_end_of_month_archive_forecast.py index 1f25cc0d9..671601082 100644 --- a/future_years/test/test_end_of_month_archive_forecast.py +++ b/future_years/test/test_end_of_month_archive_forecast.py @@ -2,12 +2,12 @@ from core.utils.generic_helpers import get_current_financial_year from end_of_month.end_of_month_actions import end_of_month_archive -from end_of_month.test.test_end_of_month_process import ReadArchivedForecastTest +from end_of_month.test.test_end_of_month_process import TestReadArchivedForecastTest from end_of_month.test.test_utils import MonthlyFigureSetup from forecast.models import ForecastMonthlyFigure -class ReadArchivedFutureDataForecast(ReadArchivedForecastTest): +class ReadArchivedFutureDataForecast(TestReadArchivedForecastTest, TestCase): def setUp(self): super().setUp() current_year = get_current_financial_year() diff --git a/makefile b/makefile index 15f8e4cd7..a49a52af2 100644 --- a/makefile +++ b/makefile @@ -95,7 +95,7 @@ test: docker-compose run --rm web python manage.py test $(test) pytest: - docker-compose run --rm web pytest --ignore=node_modules --ignore=front_end --ignore=features --ignore=staticfiles -v --random-order + docker-compose run --rm web pytest --ignore=node_modules --ignore=front_end --ignore=features --ignore=staticfiles --random-order -n 4 -v black-check: docker-compose run --rm --no-deps web black --check .