@@ 294-318 (lines=25) @@ | ||
291 | assert current_data["description"] == "Setting a maintenance id is not allowed" |
|
292 | self.scheduler.add.assert_not_called() |
|
293 | ||
294 | async def test_create_mw_case_9(self): |
|
295 | """Test a fail case of the REST to create a maintenance window.""" |
|
296 | self.napp.controller.loop = asyncio.get_running_loop() |
|
297 | url = f"{self.base_endpoint}" |
|
298 | start = datetime.now(pytz.utc) + timedelta(days=1) |
|
299 | end = start + timedelta(hours=2) |
|
300 | payload = { |
|
301 | "status": "fun", |
|
302 | "start": start.strftime(TIME_FMT), |
|
303 | "end": end.strftime(TIME_FMT), |
|
304 | "switches": [ |
|
305 | "00:00:00:00:00:00:02", |
|
306 | ], |
|
307 | "interfaces": [ |
|
308 | "00:00:00:00:00:00:00:03:3", |
|
309 | ], |
|
310 | } |
|
311 | response = await self.api.post(url, json=payload) |
|
312 | current_data = response.json() |
|
313 | ||
314 | assert response.status_code == 400 |
|
315 | assert ( |
|
316 | current_data["description"] == "Setting a maintenance status is not allowed" |
|
317 | ) |
|
318 | self.scheduler.add.assert_not_called() |
|
319 | ||
320 | async def test_get_mw_case_1(self): |
|
321 | """Test get all maintenance windows, empty list.""" |
|
@@ 269-292 (lines=24) @@ | ||
266 | assert current_data["description"] == "end: Value error, End before start not allowed" |
|
267 | self.scheduler.add.assert_not_called() |
|
268 | ||
269 | @pytest.mark.skip(reason="Future feature") |
|
270 | async def test_create_mw_case_8(self): |
|
271 | """Test a fail case of the REST to create a maintenance window.""" |
|
272 | self.napp.controller.loop = asyncio.get_running_loop() |
|
273 | url = f"{self.base_endpoint}" |
|
274 | start = datetime.now(pytz.utc) + timedelta(days=1) |
|
275 | end = start + timedelta(hours=2) |
|
276 | payload = { |
|
277 | "id": "1234", |
|
278 | "start": start.strftime(TIME_FMT), |
|
279 | "end": end.strftime(TIME_FMT), |
|
280 | "switches": [ |
|
281 | "00:00:00:00:00:00:02", |
|
282 | ], |
|
283 | "interfaces": [ |
|
284 | "00:00:00:00:00:00:00:03:3", |
|
285 | ], |
|
286 | } |
|
287 | response = await self.api.post(url, json=payload) |
|
288 | current_data = response.json() |
|
289 | ||
290 | assert response.status_code == 400 |
|
291 | assert current_data["description"] == "Setting a maintenance id is not allowed" |
|
292 | self.scheduler.add.assert_not_called() |
|
293 | ||
294 | async def test_create_mw_case_9(self): |
|
295 | """Test a fail case of the REST to create a maintenance window.""" |
|
@@ 246-267 (lines=22) @@ | ||
243 | assert current_data["description"] == "start: Value error, Start in the past not allowed" |
|
244 | self.scheduler.add.assert_not_called() |
|
245 | ||
246 | async def test_create_mw_case_7(self): |
|
247 | """Test a fail case of the REST to create a maintenance window.""" |
|
248 | self.napp.controller.loop = asyncio.get_running_loop() |
|
249 | url = f"{self.base_endpoint}" |
|
250 | start = datetime.now(pytz.utc) + timedelta(days=1) |
|
251 | end = start - timedelta(hours=2) |
|
252 | payload = { |
|
253 | "start": start.strftime(TIME_FMT), |
|
254 | "end": end.strftime(TIME_FMT), |
|
255 | "switches": [ |
|
256 | "00:00:00:00:00:00:02", |
|
257 | ], |
|
258 | "interfaces": [ |
|
259 | "00:00:00:00:00:00:00:03:3", |
|
260 | ], |
|
261 | } |
|
262 | response = await self.api.post(url, json=payload) |
|
263 | current_data = response.json() |
|
264 | ||
265 | assert response.status_code == 400 |
|
266 | assert current_data["description"] == "end: Value error, End before start not allowed" |
|
267 | self.scheduler.add.assert_not_called() |
|
268 | ||
269 | @pytest.mark.skip(reason="Future feature") |
|
270 | async def test_create_mw_case_8(self): |
|
@@ 224-244 (lines=21) @@ | ||
221 | assert response.status_code == 400 |
|
222 | self.scheduler.add.assert_not_called() |
|
223 | ||
224 | async def test_create_mw_case_6(self): |
|
225 | """Test a fail case of the REST to create a maintenance window.""" |
|
226 | self.napp.controller.loop = asyncio.get_running_loop() |
|
227 | url = f"{self.base_endpoint}" |
|
228 | start = datetime.now(pytz.utc) - timedelta(days=1) |
|
229 | end = start + timedelta(hours=2) |
|
230 | payload = { |
|
231 | "start": start.strftime(TIME_FMT), |
|
232 | "end": end.strftime(TIME_FMT), |
|
233 | "switches": [ |
|
234 | "00:00:00:00:00:00:02", |
|
235 | ], |
|
236 | "interfaces": [ |
|
237 | "00:00:00:00:00:00:00:03:3", |
|
238 | ], |
|
239 | } |
|
240 | response = await self.api.post(url, json=payload) |
|
241 | current_data = response.json() |
|
242 | assert response.status_code == 400 |
|
243 | assert current_data["description"] == "start: Value error, Start in the past not allowed" |
|
244 | self.scheduler.add.assert_not_called() |
|
245 | ||
246 | async def test_create_mw_case_7(self): |
|
247 | """Test a fail case of the REST to create a maintenance window.""" |