|
@@ 151-174 (lines=24) @@
|
| 148 |
|
'Setting a maintenance id is not allowed' |
| 149 |
|
self.scheduler.add.assert_not_called() |
| 150 |
|
|
| 151 |
|
async def test_create_mw_case_6(self, event_loop): |
| 152 |
|
"""Test a fail case of the REST to create a maintenance window.""" |
| 153 |
|
self.napp.controller.loop = event_loop |
| 154 |
|
url = f'{self.base_endpoint}' |
| 155 |
|
start = datetime.now(pytz.utc) + timedelta(days=1) |
| 156 |
|
end = start + timedelta(hours=2) |
| 157 |
|
payload = { |
| 158 |
|
'status': 'fun', |
| 159 |
|
"start": start.strftime(TIME_FMT), |
| 160 |
|
"end": end.strftime(TIME_FMT), |
| 161 |
|
"switches": [ |
| 162 |
|
"00:00:00:00:00:00:02", |
| 163 |
|
], |
| 164 |
|
'interfaces': [ |
| 165 |
|
"00:00:00:00:00:00:00:03:3", |
| 166 |
|
], |
| 167 |
|
} |
| 168 |
|
response = await self.api.post(url, json=payload) |
| 169 |
|
current_data = response.json() |
| 170 |
|
|
| 171 |
|
assert response.status_code == 400 |
| 172 |
|
assert current_data['description'] == \ |
| 173 |
|
'Setting a maintenance status is not allowed' |
| 174 |
|
self.scheduler.add.assert_not_called() |
| 175 |
|
|
| 176 |
|
async def test_get_mw_case_1(self): |
| 177 |
|
"""Test get all maintenance windows, empty list.""" |
|
@@ 126-149 (lines=24) @@
|
| 123 |
|
'End before start not allowed' |
| 124 |
|
self.scheduler.add.assert_not_called() |
| 125 |
|
|
| 126 |
|
async def test_create_mw_case_5(self, event_loop): |
| 127 |
|
"""Test a fail case of the REST to create a maintenance window.""" |
| 128 |
|
self.napp.controller.loop = event_loop |
| 129 |
|
url = f'{self.base_endpoint}' |
| 130 |
|
start = datetime.now(pytz.utc) + timedelta(days=1) |
| 131 |
|
end = start + timedelta(hours=2) |
| 132 |
|
payload = { |
| 133 |
|
'id': '1234', |
| 134 |
|
"start": start.strftime(TIME_FMT), |
| 135 |
|
"end": end.strftime(TIME_FMT), |
| 136 |
|
"switches": [ |
| 137 |
|
"00:00:00:00:00:00:02", |
| 138 |
|
], |
| 139 |
|
'interfaces': [ |
| 140 |
|
"00:00:00:00:00:00:00:03:3", |
| 141 |
|
], |
| 142 |
|
} |
| 143 |
|
response = await self.api.post(url, json=payload) |
| 144 |
|
current_data = response.json() |
| 145 |
|
|
| 146 |
|
assert response.status_code == 400 |
| 147 |
|
assert current_data['description'] == \ |
| 148 |
|
'Setting a maintenance id is not allowed' |
| 149 |
|
self.scheduler.add.assert_not_called() |
| 150 |
|
|
| 151 |
|
async def test_create_mw_case_6(self, event_loop): |
| 152 |
|
"""Test a fail case of the REST to create a maintenance window.""" |
|
@@ 102-124 (lines=23) @@
|
| 99 |
|
'Start in the past not allowed' |
| 100 |
|
self.scheduler.add.assert_not_called() |
| 101 |
|
|
| 102 |
|
async def test_create_mw_case_4(self, event_loop): |
| 103 |
|
"""Test a fail case of the REST to create a maintenance window.""" |
| 104 |
|
self.napp.controller.loop = event_loop |
| 105 |
|
url = f'{self.base_endpoint}' |
| 106 |
|
start = datetime.now(pytz.utc) + timedelta(days=1) |
| 107 |
|
end = start - timedelta(hours=2) |
| 108 |
|
payload = { |
| 109 |
|
"start": start.strftime(TIME_FMT), |
| 110 |
|
"end": end.strftime(TIME_FMT), |
| 111 |
|
"switches": [ |
| 112 |
|
"00:00:00:00:00:00:02", |
| 113 |
|
], |
| 114 |
|
'interfaces': [ |
| 115 |
|
"00:00:00:00:00:00:00:03:3", |
| 116 |
|
], |
| 117 |
|
} |
| 118 |
|
response = await self.api.post(url, json=payload) |
| 119 |
|
current_data = response.json() |
| 120 |
|
|
| 121 |
|
assert response.status_code == 400 |
| 122 |
|
assert current_data['description'] == \ |
| 123 |
|
'End before start not allowed' |
| 124 |
|
self.scheduler.add.assert_not_called() |
| 125 |
|
|
| 126 |
|
async def test_create_mw_case_5(self, event_loop): |
| 127 |
|
"""Test a fail case of the REST to create a maintenance window.""" |
|
@@ 79-100 (lines=22) @@
|
| 76 |
|
assert response.status_code == 400 |
| 77 |
|
self.scheduler.add.assert_not_called() |
| 78 |
|
|
| 79 |
|
async def test_create_mw_case_3(self, event_loop): |
| 80 |
|
"""Test a fail case of the REST to create a maintenance window.""" |
| 81 |
|
self.napp.controller.loop = event_loop |
| 82 |
|
url = f'{self.base_endpoint}' |
| 83 |
|
start = datetime.now(pytz.utc) - timedelta(days=1) |
| 84 |
|
end = start + timedelta(hours=2) |
| 85 |
|
payload = { |
| 86 |
|
"start": start.strftime(TIME_FMT), |
| 87 |
|
"end": end.strftime(TIME_FMT), |
| 88 |
|
"switches": [ |
| 89 |
|
"00:00:00:00:00:00:02", |
| 90 |
|
], |
| 91 |
|
'interfaces': [ |
| 92 |
|
"00:00:00:00:00:00:00:03:3", |
| 93 |
|
], |
| 94 |
|
} |
| 95 |
|
response = await self.api.post(url, json=payload) |
| 96 |
|
current_data = response.json() |
| 97 |
|
assert response.status_code == 400 |
| 98 |
|
assert current_data['description'] == \ |
| 99 |
|
'Start in the past not allowed' |
| 100 |
|
self.scheduler.add.assert_not_called() |
| 101 |
|
|
| 102 |
|
async def test_create_mw_case_4(self, event_loop): |
| 103 |
|
"""Test a fail case of the REST to create a maintenance window.""" |