Skip to content

Commit 3c6ec6a

Browse files
Reduce flakiness of export tests
1 parent 2107b8f commit 3c6ec6a

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

mavis/test/data_models.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,20 @@ def to_onboarding(self) -> str:
6666

6767
@classmethod
6868
def get_from_testing_api(
69-
cls, base_url: str, year_groups: dict[str, int]
69+
cls,
70+
base_url: str,
71+
year_groups: dict[str, int],
72+
*,
73+
required_year_groups: list[int] | None = None,
7074
) -> "dict[str, list[School]]":
7175
def _get_schools_with_year_group(year_group: int) -> list[School]:
76+
filter_groups = required_year_groups if required_year_groups else [year_group]
7277
url = urllib.parse.urljoin(base_url, "api/testing/locations")
7378
params = {
7479
"type": "gias_school",
7580
"status": "open",
7681
"is_attached_to_team": "false",
77-
"gias_year_groups[]": [str(year_group)],
82+
"gias_year_groups[]": [str(yg) for yg in filter_groups],
7883
"site": "",
7984
}
8085

mavis/test/onboarding.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,20 @@ class PointOfCareOnboarding(Onboarding):
6161

6262
@classmethod
6363
def get_onboarding_data_for_tests(
64-
cls, base_url: str, year_groups: dict[str, int]
64+
cls,
65+
base_url: str,
66+
year_groups: dict[str, int],
67+
*,
68+
required_year_groups: list[int] | None = None,
6569
) -> "PointOfCareOnboarding":
6670
organisation = Organisation.generate()
6771
subteam = Subteam.generate()
6872
team = PointOfCareTeam.generate(subteam, organisation)
6973
users = cls._generate_users()
7074
clinics = [Clinic.generate()]
71-
schools = School.get_from_testing_api(base_url, year_groups)
75+
schools = School.get_from_testing_api(
76+
base_url, year_groups, required_year_groups=required_year_groups
77+
)
7278

7379
return cls(
7480
organisation=organisation,

tests/test_reporting_regression.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def _onboard_team(base_url):
4141
onboarding = PointOfCareOnboarding.get_onboarding_data_for_tests(
4242
base_url=base_url,
4343
year_groups=_year_groups,
44+
required_year_groups=[_yg1, _yg2, _yg3],
4445
)
4546
return _create_onboarding_with_retry(base_url, onboarding)
4647

0 commit comments

Comments
 (0)