Skip to content

Commit 82a5634

Browse files
committed
fixup! tests: adapt fuzzer for timetable v2
1 parent 779c0ea commit 82a5634

File tree

1 file changed

+5
-49
lines changed

1 file changed

+5
-49
lines changed

tests/fuzzer/fuzzer_v2.py

+5-49
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def run(
8484
# Let's reset the scenario (empty timetable) so we can keep a
8585
# manageable/reproducible state.
8686
if seed % scenario_ttl == 0:
87-
scenario = _reset_scenario(editoast_url, scenario)
87+
scenario = _reset_timetable(editoast_url, scenario)
8888
prelude = []
8989

9090

@@ -110,35 +110,10 @@ def get_infra(editoast_url: str, infra_name: str) -> int:
110110

111111

112112
def create_scenario(editoast_url: str, infra_id: int) -> Scenario:
113-
# Create the project
114-
project_payload = {"name": "fuzzer_project"}
115-
r = _post_with_timeout(editoast_url + "projects/", json=project_payload)
116-
r.raise_for_status()
117-
project_id = r.json()["id"]
118-
project_url = f"projects/{project_id}"
119-
120-
# Create the study
121-
study_payload = {"name": "fuzzer_study", "state": "Starting"}
122-
r = _post_with_timeout(editoast_url + f"{project_url}/studies/", json=study_payload)
123-
r.raise_for_status()
124-
study_id = r.json()["id"]
125-
study_url = f"{project_url}/studies/{study_id}"
126-
127113
# Create the timetable
128114
r = _post_with_timeout(editoast_url + "v2/timetable/", json={})
129115
timetable_id = r.json()["id"]
130-
131-
# Create the scenario
132-
scenario_payload = {
133-
"name": "fuzzer_scenario",
134-
"infra_id": infra_id,
135-
"timetable_id": timetable_id,
136-
}
137-
r = _post_with_timeout(editoast_url + f"v2/{study_url}/scenarios/", json=scenario_payload)
138-
r.raise_for_status()
139-
timetable_id = r.json()["timetable_id"]
140-
id = r.json()["id"]
141-
return Scenario(project_id, study_id, id, infra_id, timetable_id)
116+
return Scenario(-1, -1, -1, infra_id, timetable_id)
142117

143118

144119
class _FailedTest(Exception):
@@ -486,35 +461,16 @@ def _convert_stop(stop: Tuple[str, float], i: int) -> Dict:
486461
return {"offset": _to_mm(offset), "track": track_section, "id": str(i)}
487462

488463

489-
def _reset_scenario(editoast_url: str, scenario: Scenario) -> Scenario:
490-
"""Deletes the current scenario and creates a new one."""
491-
print("scenario reset")
492-
project_id, study_id, infra_id = scenario.project, scenario.op_study, scenario.infra
493-
494-
# Delete the current scenario
495-
study_url = f"v2/projects/{project_id}/studies/{study_id}"
496-
r = _delete_with_timeout(editoast_url + study_url + f"/scenarios/{scenario.scenario}")
497-
r.raise_for_status()
498-
464+
def _reset_timetable(editoast_url: str, scenario: Scenario) -> Scenario:
465+
"""Deletes the current timetable and creates a new one."""
499466
# Delete the current timetable
500467
r = _delete_with_timeout(editoast_url + f"/v2/timetable/{scenario.timetable}/")
501468
r.raise_for_status()
502469

503470
# Create a timetable
504471
r = _post_with_timeout(editoast_url + "v2/timetable/", json={})
505472
timetable_id = r.json()["id"]
506-
507-
# Create a new scenario
508-
new_scenario_payload = {
509-
"name": "fuzzer_scenario",
510-
"infra_id": infra_id,
511-
"timetable_id": timetable_id,
512-
}
513-
r = _post_with_timeout(editoast_url + f"{study_url}/scenarios/", json=new_scenario_payload)
514-
r.raise_for_status()
515-
new_timetable_id = r.json()["timetable_id"]
516-
new_id = r.json()["id"]
517-
return Scenario(project_id, study_id, new_id, infra_id, new_timetable_id)
473+
return Scenario(-1, -1, -1, infra_id, timetable_id)
518474

519475

520476
def _make_random_margin_value() -> str:

0 commit comments

Comments
 (0)