@@ -92,8 +92,8 @@ def test_create_vacation(self) -> Vacation:
9292 url = "/api/vacations/"
9393 data = {
9494 "reason" : "annual" ,
95- "from_date" : "2022-08-23" ,
96- "end_date" : "2022-08-23" ,
95+ "from_date" : "2022-08-23:08:00:00 " ,
96+ "end_date" : "2022-08-23:17:00:00 " ,
9797 "change_log" : [],
9898 }
9999 self .headers = client .credentials (
@@ -106,8 +106,8 @@ def test_create_vacation_with_invalid_reason(self) -> Vacation:
106106 url = "/api/vacations/"
107107 data = {
108108 "reason" : "invalid" ,
109- "from_date" : "2022-08-23" ,
110- "end_date" : "2022-08-23" ,
109+ "from_date" : "2022-08-23:08:00:00 " ,
110+ "end_date" : "2022-08-23:17:00:00 " ,
111111 "change_log" : [],
112112 }
113113 self .headers = client .credentials (
@@ -147,8 +147,8 @@ def test_get_certain_vacation_request(self) -> Vacation:
147147 url = "/api/vacations/"
148148 data = {
149149 "reason" : "annual" ,
150- "from_date" : "2022-08-23" ,
151- "end_date" : "2022-08-23" ,
150+ "from_date" : "2022-08-23:08:00:00 " ,
151+ "end_date" : "2022-08-23:17:00:00 " ,
152152 "change_log" : [],
153153 }
154154 self .headers = client .credentials (
@@ -166,8 +166,8 @@ def test_get_invalid_vacation_request(self) -> Vacation:
166166 url = "/api/vacations/"
167167 data = {
168168 "reason" : "annual" ,
169- "from_date" : "2022-08-23" ,
170- "end_date" : "2022-08-23" ,
169+ "from_date" : "2022-08-23:08:00:00 " ,
170+ "end_date" : "2022-08-23:17:00:00 " ,
171171 "change_log" : [],
172172 }
173173 self .headers = client .credentials (
@@ -184,8 +184,8 @@ def test_cancel_certain_vacation_request(self) -> Vacation:
184184 url = "/api/vacations/"
185185 data = {
186186 "reason" : "annual" ,
187- "from_date" : "2022-08-23" ,
188- "end_date" : "2022-08-23" ,
187+ "from_date" : "2022-08-23:08:00:00 " ,
188+ "end_date" : "2022-08-23:17:00:00 " ,
189189 "change_log" : [],
190190 }
191191 self .headers = client .credentials (
@@ -221,8 +221,8 @@ def test_update_vacation_request_invalid_user_id(self) -> Vacation:
221221 url = "/api/vacations/"
222222 data = {
223223 "reason" : "annual" ,
224- "from_date" : "2022-08-23" ,
225- "end_date" : "2022-08-23" ,
224+ "from_date" : "2022-08-23:08:00:00 " ,
225+ "end_date" : "2022-08-23:17:00:00 " ,
226226 "change_log" : [],
227227 }
228228 self .headers = client .credentials (
@@ -240,8 +240,8 @@ def test_user_updates_status(self) -> Vacation:
240240 url = "/api/vacations/"
241241 data = {
242242 "reason" : "annual" ,
243- "from_date" : "2022-08-23" ,
244- "end_date" : "2022-08-23" ,
243+ "from_date" : "2022-08-23:08:00:00 " ,
244+ "end_date" : "2022-08-23:17:00:00 " ,
245245 "change_log" : [],
246246 }
247247 self .headers = client .credentials (
@@ -259,8 +259,8 @@ def test_get_vacations_for_user_with_data(self) -> Vacation:
259259 url = "/api/vacations/"
260260 data = {
261261 "reason" : "annual" ,
262- "from_date" : "2022-08-23" ,
263- "end_date" : "2022-08-23" ,
262+ "from_date" : "2022-08-23:08:00:00 " ,
263+ "end_date" : "2022-08-23:17:00:00 " ,
264264 "change_log" : [],
265265 }
266266 self .headers = client .credentials (
@@ -285,8 +285,8 @@ def test_accept_vacation_for_unauthorized_user(self) -> Vacation:
285285 url = "/api/vacations/"
286286 data = {
287287 "reason" : "annual" ,
288- "from_date" : "2022-08-23" ,
289- "end_date" : "2022-08-23" ,
288+ "from_date" : "2022-08-23:08:00:00 " ,
289+ "end_date" : "2022-08-23:17:00:00 " ,
290290 "change_log" : [],
291291 }
292292 self .headers = client .credentials (
@@ -303,8 +303,8 @@ def test_reject_vacation_for_unauthorized_user(self) -> Vacation:
303303 url = "/api/vacations/"
304304 data = {
305305 "reason" : "annual" ,
306- "from_date" : "2022-08-23" ,
307- "end_date" : "2022-08-23" ,
306+ "from_date" : "2022-08-23:08:00:00 " ,
307+ "end_date" : "2022-08-23:17:00:00 " ,
308308 "change_log" : [],
309309 }
310310 self .headers = client .credentials (
@@ -321,8 +321,8 @@ def test_accept_vacation_for_supervisor_auth(self) -> Vacation:
321321 url = "/api/vacations/"
322322 data = {
323323 "reason" : "annual" ,
324- "from_date" : "2022-08-23" ,
325- "end_date" : "2022-08-23" ,
324+ "from_date" : "2022-08-23:08:00:00 " ,
325+ "end_date" : "2022-08-23:17:00:00 " ,
326326 "change_log" : [],
327327 }
328328 self .headers = client .credentials (
@@ -341,8 +341,8 @@ def test_reject_vacation_for_supervisor_auth(self) -> Vacation:
341341 url = "/api/vacations/"
342342 data = {
343343 "reason" : "annual" ,
344- "from_date" : "2022-08-23" ,
345- "end_date" : "2022-08-23" ,
344+ "from_date" : "2022-08-23:08:00:00 " ,
345+ "end_date" : "2022-08-23:17:00:00 " ,
346346 "change_log" : [],
347347 }
348348 self .headers = client .credentials (
@@ -361,8 +361,8 @@ def test_reject_invalid_vacation(self) -> Vacation:
361361 url = "/api/vacations/"
362362 data = {
363363 "reason" : "annual" ,
364- "from_date" : "2022-08-23" ,
365- "end_date" : "2022-08-23" ,
364+ "from_date" : "2022-08-23:08:00:00 " ,
365+ "end_date" : "2022-08-23:17:00:00 " ,
366366 "change_log" : [],
367367 }
368368 self .headers = client .credentials (
@@ -379,8 +379,8 @@ def test_accept_invalid_vacation(self) -> Vacation:
379379 url = "/api/vacations/"
380380 data = {
381381 "reason" : "annual" ,
382- "from_date" : "2022-08-23" ,
383- "end_date" : "2022-08-23" ,
382+ "from_date" : "2022-08-23:08:00:00 " ,
383+ "end_date" : "2022-08-23:17:00:00 " ,
384384 "change_log" : [],
385385 }
386386 self .headers = client .credentials (
@@ -485,7 +485,7 @@ def test_update_annual_to_excuse_with_valid_duration(self) -> Vacation:
485485 data = {
486486 "reason" : "annual" ,
487487 "from_date" : "2022-08-23:08:00:00" ,
488- "end_date" : "2022-08-23:10 :00:00" ,
488+ "end_date" : "2022-08-23:17 :00:00" ,
489489 "change_log" : [],
490490 }
491491 self .headers = client .credentials (
@@ -529,3 +529,21 @@ def test_update_annual_to_excuse_with_invalid_duration(self) -> Vacation:
529529 }
530530 response = client .put (url , data , format = "json" )
531531 self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
532+
533+ def test_invalid_annual_vacation_duration (self ) -> Vacation :
534+ url = "/api/vacations/"
535+ data = {
536+ "reason" : "annual" ,
537+ "from_date" : "2022-08-23:08:00:00" ,
538+ "end_date" : "2022-08-23:10:00:00" ,
539+ "change_log" : [],
540+ }
541+ self .headers = client .credentials (
542+ HTTP_AUTHORIZATION = "Bearer " + self .access_token_user
543+ )
544+ response = client .post (url , data , format = "json" )
545+ self .assertEqual (
546+ response .data .get ("message" ),
547+ "Vacation duration cannot be less than 0.5 days." ,
548+ )
549+ self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
0 commit comments