@@ -41,24 +41,30 @@ def tearDownClass(cls):
41
41
42
42
def setUp (self ):
43
43
self .tomorrow = timezone .now ().date () + datetime .timedelta (days = 1 )
44
- ar = self .create_appt_request_for_sm1 (date_ = self .tomorrow )
44
+ ar = self .create_appt_request_for_sm1 (date_ = self .tomorrow , start_time = time ( 11 , 0 ), end_time = time ( 12 , 0 ) )
45
45
self .appointment = self .create_appt_for_sm1 (appointment_request = ar )
46
46
47
+ @override_settings (DEBUG = True )
48
+ def tearDown (self ):
49
+ Config .objects .all ().delete ()
50
+ super ().tearDown ()
51
+ cache .clear ()
52
+
47
53
def test_get_available_slots (self ):
48
54
slots = get_available_slots (self .tomorrow , [self .appointment ])
49
55
self .assertIsInstance (slots , list )
50
- self .assertNotIn ('09 :00 AM' , slots )
56
+ self .assertNotIn ('11 :00 AM' , slots )
51
57
52
58
def test_get_available_slots_with_config (self ):
53
59
Config .objects .create (
54
- lead_time = datetime .time (8 , 0 ),
55
- finish_time = datetime .time (17 , 0 ),
60
+ lead_time = datetime .time (11 , 0 ),
61
+ finish_time = datetime .time (15 , 0 ),
56
62
slot_duration = 30 ,
57
63
appointment_buffer_time = 2.0
58
64
)
59
65
slots = get_available_slots (self .tomorrow , [self .appointment ])
60
66
self .assertIsInstance (slots , list )
61
- self .assertNotIn ('09 :00 AM' , slots )
67
+ self .assertNotIn ('11 :00 AM' , slots )
62
68
63
69
64
70
class FetchUserAppointmentsTests (BaseTest ):
@@ -244,6 +250,13 @@ def test_regular_user_with_non_existent_staff_user_id(self):
244
250
245
251
246
252
class HandleEntityManagementRequestTests (BaseTest ):
253
+ @classmethod
254
+ def setUpClass (cls ):
255
+ super ().setUpClass ()
256
+
257
+ @classmethod
258
+ def tearDownClass (cls ):
259
+ super ().tearDownClass ()
247
260
248
261
def setUp (self ):
249
262
super ().setUp ()
@@ -254,6 +267,10 @@ def setUp(self):
254
267
self .request = self .factory .post ('/' )
255
268
self .request .user = self .staff_member1 .user
256
269
270
+ def tearDown (self ):
271
+ WorkingHours .objects .all ().delete ()
272
+ super ().tearDown ()
273
+
257
274
def test_staff_member_none (self ):
258
275
"""A day off cannot be created for a staff member that doesn't exist."""
259
276
response = handle_entity_management_request (self .request , None , 'day_off' )
@@ -318,10 +335,21 @@ def test_working_hours_post(self):
318
335
319
336
320
337
class HandleWorkingHoursFormTest (BaseTest ):
338
+ @classmethod
339
+ def setUpClass (cls ):
340
+ super ().setUpClass ()
341
+
342
+ @classmethod
343
+ def tearDownClass (cls ):
344
+ super ().tearDownClass ()
321
345
322
346
def setUp (self ):
323
347
super ().setUp ()
324
348
349
+ def tearDown (self ):
350
+ WorkingHours .objects .all ().delete ()
351
+ super ().tearDown ()
352
+
325
353
def test_add_working_hours (self ):
326
354
"""Test if working hours can be added."""
327
355
response = handle_working_hours_form (self .staff_member1 , 1 , '09:00 AM' , '05:00 PM' , True )
@@ -535,6 +563,14 @@ def setUp(self):
535
563
Config .objects .create (slot_duration = 60 , lead_time = datetime .time (9 , 0 ), finish_time = datetime .time (17 , 0 ),
536
564
appointment_buffer_time = 0 )
537
565
566
+ @override_settings (DEBUG = True )
567
+ def tearDown (self ):
568
+ WorkingHours .objects .all ().delete ()
569
+ DayOff .objects .all ().delete ()
570
+ Config .objects .all ().delete ()
571
+ cache .clear ()
572
+ super ().tearDown ()
573
+
538
574
def test_day_off (self ):
539
575
"""Test if a day off is handled correctly when getting available slots."""
540
576
# Ask for slots for it, and it should return an empty list since next Monday is a day off
@@ -587,6 +623,7 @@ def test_booked_slots(self):
587
623
hour in range (9 , 17 ) if hour != 10 ]
588
624
self .assertEqual (slots , expected_slots )
589
625
626
+ @override_settings (DEBUG = True )
590
627
def test_no_working_hours (self ):
591
628
"""If a staff member doesn't have working hours on a given day, no slots should be available."""
592
629
# Let's ask for slots on a Thursday, which the staff member doesn't work
@@ -856,6 +893,14 @@ def test_get_finish_button_text_paid_service(self):
856
893
857
894
class SlotAvailabilityTest (BaseTest , ConfigMixin ):
858
895
896
+ @classmethod
897
+ def setUpClass (cls ):
898
+ super ().setUpClass ()
899
+
900
+ @classmethod
901
+ def tearDownClass (cls ):
902
+ super ().tearDownClass ()
903
+
859
904
def setUp (self ):
860
905
self .service = self .create_service_ (duration = timedelta (hours = 2 ))
861
906
self .config = self .create_config_ (lead_time = time (11 , 0 ), finish_time = time (15 , 0 ), slot_duration = 120 )
@@ -864,7 +909,6 @@ def setUp(self):
864
909
@override_settings (DEBUG = True )
865
910
def tearDown (self ):
866
911
self .service .delete ()
867
- self .config .delete ()
868
912
cache .clear ()
869
913
870
914
def test_slot_availability_without_appointments (self ):
0 commit comments