Skip to content

Commit 463e5d1

Browse files
committed
Add tests
1 parent 3ba9e61 commit 463e5d1

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

core/src/main/java/fr/sncf/osrd/api/stdcm/STDCMRequest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public final class STDCMRequest {
7575
public double endTime;
7676

7777
/**
78-
* Time step used in simulations
78+
* Time step used in simulations (defaults to 2)
7979
*/
8080
@Json(name = "time_step")
8181
public double timeStep = 2.;
@@ -102,15 +102,15 @@ public final class STDCMRequest {
102102
public String speedLimitComposition = null;
103103

104104
/**
105-
* Margin of x seconds before the train passage,
105+
* Grid margin of x seconds before the train passage,
106106
* which means that the path used by the train should be free and available
107107
* at least x seconds before its passage.
108108
*/
109109
@Json(name = "margin_before")
110110
public double marginBefore = 0;
111111

112112
/**
113-
* Margin of y seconds after the train passage,
113+
* Grid margin of y seconds after the train passage,
114114
* which means that the path used by the train should be free and available
115115
* at least y seconds after its passage.
116116
*/
@@ -131,8 +131,8 @@ public STDCMRequest() {
131131
Double.NaN,
132132
Double.NaN,
133133
null,
134-
Double.NaN,
135-
Double.NaN
134+
0,
135+
0
136136
);
137137
}
138138

core/src/test/java/fr/sncf/osrd/stdcm/UnavailableSpaceBuilderTests.java

+29
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,33 @@ public void testThirdRoute() {
152152
res.get(thirdRoute)
153153
);
154154
}
155+
156+
@Test
157+
public void testMargins() {
158+
var infraBuilder = new DummyRouteGraphBuilder();
159+
var firstRoute = infraBuilder.addRoute("a", "b", 1000);
160+
var secondRoute = infraBuilder.addRoute("b", "c", 1000);
161+
var infra = infraBuilder.build();
162+
var res = computeUnavailableSpace(
163+
infra,
164+
Set.of(new STDCMRequest.RouteOccupancy("a->b", 100, 200)),
165+
REALISTIC_FAST_TRAIN,
166+
20,
167+
60
168+
);
169+
// TimeStart and TimeEnd should be adjusted because of the margins
170+
// (20s before and 60s after)
171+
assertEquals(
172+
Set.of(
173+
new OccupancyBlock(80, 260, 0, 1000)
174+
),
175+
res.get(firstRoute)
176+
);
177+
assertEquals(
178+
Set.of(
179+
new OccupancyBlock(80, 260, 0, 1000)
180+
),
181+
res.get(secondRoute)
182+
);
183+
}
155184
}

tests/fuzzer/fuzzer.py

-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ def make_stdcm_payload(base_url: str, infra_id: int, path: List[Tuple[str, float
167167
"track_section": last_edge,
168168
"offset": last_offset,
169169
}],
170-
"margin_before": 0,
171-
"margin_after": 0,
172170
}
173171

174172

tests/tests/stdcm/between_trains.py

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def run(*args, **kwargs):
2727
"name": "foo",
2828
"start_points": [start],
2929
"end_points": [stop],
30-
"margin_before": 0,
31-
"margin_after": 0
3230
}
3331
r = requests.post(base_url + f"stdcm/", json=payload)
3432
delete_timetable(base_url, timetable)

tests/tests/stdcm/empty_timetable.py

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ def run(*args, **kwargs):
2121
"track_section": "TE0",
2222
"offset": 0
2323
}],
24-
"margin_before": 0,
25-
"margin_after": 0
2624
}
2725
r = requests.post(base_url + f"stdcm/", json=payload)
2826
delete_timetable(base_url, timetable)

0 commit comments

Comments
 (0)