@@ -23,39 +23,18 @@ def setUp(self):
23
23
frappe .db .delete ("Shift Assignment" )
24
24
frappe .db .delete ("Shift Type" )
25
25
26
- def test_make_shift_assignment (self ):
27
- setup_shift_type (shift_type = "Day Shift" )
28
- shift_assignment = frappe .get_doc (
29
- {
30
- "doctype" : "Shift Assignment" ,
31
- "shift_type" : "Day Shift" ,
32
- "company" : "_Test Company" ,
33
- "employee" : "_T-Employee-00001" ,
34
- "start_date" : nowdate (),
35
- }
36
- ).insert ()
37
- shift_assignment .submit ()
38
-
39
- self .assertEqual (shift_assignment .docstatus , 1 )
40
-
41
26
def test_overlapping_for_ongoing_shift (self ):
42
27
# shift should be Ongoing if Only start_date is present and status = Active
43
28
setup_shift_type (shift_type = "Day Shift" )
44
- shift_assignment_1 = frappe .get_doc (
45
- {
46
- "doctype" : "Shift Assignment" ,
47
- "shift_type" : "Day Shift" ,
48
- "company" : "_Test Company" ,
49
- "employee" : "_T-Employee-00001" ,
50
- "start_date" : nowdate (),
51
- "status" : "Active" ,
52
- }
53
- ).insert ()
54
- shift_assignment_1 .submit ()
29
+ make_shift_assignment ("Day Shift" , "_T-Employee-00001" , nowdate ())
55
30
56
- self .assertEqual (shift_assignment_1 .docstatus , 1 )
31
+ # shift ends before ongoing shift starts
32
+ non_overlapping_shift = make_shift_assignment (
33
+ "Day Shift" , "_T-Employee-00001" , add_days (nowdate (), - 1 ), add_days (nowdate (), - 1 )
34
+ )
35
+ self .assertEqual (non_overlapping_shift .docstatus , 1 )
57
36
58
- shift_assignment = frappe .get_doc (
37
+ overlapping_shift = frappe .get_doc (
59
38
{
60
39
"doctype" : "Shift Assignment" ,
61
40
"shift_type" : "Day Shift" ,
@@ -64,23 +43,11 @@ def test_overlapping_for_ongoing_shift(self):
64
43
"start_date" : add_days (nowdate (), 2 ),
65
44
}
66
45
)
67
-
68
- self .assertRaises (OverlappingShiftError , shift_assignment .save )
46
+ self .assertRaises (OverlappingShiftError , overlapping_shift .save )
69
47
70
48
def test_multiple_shift_assignments_for_same_date (self ):
71
49
setup_shift_type (shift_type = "Day Shift" )
72
- shift_assignment_1 = frappe .get_doc (
73
- {
74
- "doctype" : "Shift Assignment" ,
75
- "shift_type" : "Day Shift" ,
76
- "company" : "_Test Company" ,
77
- "employee" : "_T-Employee-00001" ,
78
- "start_date" : nowdate (),
79
- "end_date" : add_days (nowdate (), 30 ),
80
- "status" : "Active" ,
81
- }
82
- ).insert ()
83
- shift_assignment_1 .submit ()
50
+ make_shift_assignment ("Day Shift" , "_T-Employee-00001" , nowdate (), add_days (nowdate (), 30 ))
84
51
85
52
setup_shift_type (shift_type = "Night Shift" , start_time = "19:00:00" , end_time = "23:00:00" )
86
53
shift_assignment_2 = frappe .get_doc (
@@ -103,18 +70,7 @@ def test_multiple_shift_assignments_for_same_date(self):
103
70
def test_overlapping_for_fixed_period_shift (self ):
104
71
# shift should is for Fixed period if Only start_date and end_date both are present and status = Active
105
72
setup_shift_type (shift_type = "Day Shift" )
106
- shift_assignment_1 = frappe .get_doc (
107
- {
108
- "doctype" : "Shift Assignment" ,
109
- "shift_type" : "Day Shift" ,
110
- "company" : "_Test Company" ,
111
- "employee" : "_T-Employee-00001" ,
112
- "start_date" : nowdate (),
113
- "end_date" : add_days (nowdate (), 30 ),
114
- "status" : "Active" ,
115
- }
116
- ).insert ()
117
- shift_assignment_1 .submit ()
73
+ make_shift_assignment ("Day Shift" , "_T-Employee-00001" , nowdate (), add_days (nowdate (), 30 ))
118
74
119
75
# it should not allowed within period of any shift.
120
76
shift_assignment_3 = frappe .get_doc (
0 commit comments