Skip to content

Commit 35c6dde

Browse files
Changing the last run util to check for enviroment first, then test name.
1 parent 6f47e63 commit 35c6dde

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

tests/regression/subject/episodes/datasets/investigation/endoscopy/polypcategories/test_setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ def before_each(page: Page, request: FixtureRequest) -> None:
8787
setup_appointments(page)
8888

8989

90-
@pytest.mark.wip
9190
def test_setup_subjects_as_a99(page: Page, subjects_to_run_for: int) -> None:
9291
"""
9392
Scenario Outline: Set up 10 subjects to be at status A99

utils/last_test_run.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def load_last_run_data() -> Dict[str, Any]:
1212
Loads the last run data from the JSON file.
1313
1414
Returns:
15-
Dict[str, Any]: A dictionary mapping test names to their last run date.
15+
Dict[str, Any]: A dictionary mapping environments to test names and their last run date.
1616
"""
1717
if os.path.exists(LAST_RUN_FILE):
1818
try:
@@ -31,31 +31,39 @@ def save_last_run_data(data: Dict[str, Any]) -> None:
3131
Saves the last run data to the JSON file.
3232
3333
Args:
34-
data (Dict[str, Any]): The data to save, mapping test names to their last run date.
34+
data (Dict[str, Any]): The data to save, mapping environments to test names and their last run date.
3535
"""
3636
with open(LAST_RUN_FILE, "w") as f:
3737
json.dump(data, f, indent=2)
3838

3939

4040
def has_test_run_today(test_name: str, base_url: Optional[str] = None) -> bool:
4141
"""
42-
Checks if the given test has already run today.
43-
If not, updates the record to mark it as run today.
42+
Checks if the given test has already run today in the given environment.
43+
If not, updates the record to mark it as run today for that environment.
4444
4545
Args:
4646
test_name (str): The name of the test to check.
47+
base_url (str, optional): The environment base URL.
4748
4849
Returns:
49-
bool: True if the test has already run today, False otherwise.
50+
bool: True if the test has already run today in this environment, False otherwise.
5051
"""
5152
data = load_last_run_data()
5253
today = date.today().isoformat()
5354
env = base_url or "unknown"
5455

55-
last_run = data.get(test_name, {})
56-
if last_run.get("date") == today and last_run.get("env") == env:
56+
# Ensure the environment key exists
57+
env_data = data.get(env, {})
58+
59+
# Check if the test has run today in this environment
60+
last_run = env_data.get(test_name, {})
61+
if last_run.get("date") == today:
5762
return True
5863
else:
59-
data[test_name] = {"date": today, "env": env}
64+
# Update only the relevant environment/test combination
65+
if env not in data:
66+
data[env] = {}
67+
data[env][test_name] = {"date": today}
6068
save_last_run_data(data)
6169
return False

0 commit comments

Comments
 (0)