@@ -104,26 +104,6 @@ def test_remove_billables(self):
104
104
self .assertNotIn ("ProjectE" , result_df ["Project - Allocation" ].tolist ())
105
105
106
106
107
- class TestBillableInvoice (TestCase ):
108
- def test_remove_nonbillables (self ):
109
- pis = [uuid .uuid4 ().hex for x in range (10 )]
110
- projects = [uuid .uuid4 ().hex for x in range (10 )]
111
- nonbillable_pis = pis [:3 ]
112
- nonbillable_projects = projects [7 :]
113
- billable_pis = pis [3 :7 ]
114
- data = pandas .DataFrame ({"Manager (PI)" : pis , "Project - Allocation" : projects })
115
-
116
- test_invoice = test_utils .new_billable_invoice ()
117
- data = test_invoice ._remove_nonbillables (
118
- data , nonbillable_pis , nonbillable_projects
119
- )
120
- self .assertTrue (data [data ["Manager (PI)" ].isin (nonbillable_pis )].empty )
121
- self .assertTrue (
122
- data [data ["Project - Allocation" ].isin (nonbillable_projects )].empty
123
- )
124
- self .assertTrue (data .equals (data [data ["Manager (PI)" ].isin (billable_pis )]))
125
-
126
-
127
107
class TestMergeCSV (TestCase ):
128
108
def setUp (self ):
129
109
self .header = ["ID" , "Name" , "Age" ]
@@ -278,6 +258,46 @@ def test_validate_alias(self):
278
258
self .assertTrue (answer_data .equals (validate_pi_alias_proc .data ))
279
259
280
260
261
+ class TestRemoveNonbillablesProcessor (TestCase ):
262
+ def test_remove_nonbillables (self ):
263
+ pis = [uuid .uuid4 ().hex for x in range (10 )]
264
+ projects = [uuid .uuid4 ().hex for x in range (10 )]
265
+ nonbillable_pis = pis [:3 ]
266
+ nonbillable_projects = projects [7 :]
267
+ billable_pis = pis [3 :7 ]
268
+ data = pandas .DataFrame ({"Manager (PI)" : pis , "Project - Allocation" : projects })
269
+
270
+ remove_nonbillables_proc = test_utils .new_remove_nonbillables_processor ()
271
+ data = remove_nonbillables_proc ._remove_nonbillables (
272
+ data , nonbillable_pis , nonbillable_projects
273
+ )
274
+ self .assertTrue (data [data ["Manager (PI)" ].isin (nonbillable_pis )].empty )
275
+ self .assertTrue (
276
+ data [data ["Project - Allocation" ].isin (nonbillable_projects )].empty
277
+ )
278
+ self .assertTrue (data .equals (data [data ["Manager (PI)" ].isin (billable_pis )]))
279
+
280
+
281
+ class TestValidateBillablePIProcessor (TestCase ):
282
+ def test_validate_billables (self ):
283
+ test_data = pandas .DataFrame (
284
+ {
285
+ "Manager (PI)" : ["PI1" , math .nan , "PI1" , "PI2" , "PI2" ],
286
+ "Project - Allocation" : [
287
+ "ProjectA" ,
288
+ "ProjectB" ,
289
+ "ProjectC" ,
290
+ "ProjectD" ,
291
+ "ProjectE" ,
292
+ ],
293
+ }
294
+ )
295
+ self .assertEqual (1 , len (test_data [pandas .isna (test_data ["Manager (PI)" ])]))
296
+ validate_billable_pi_proc = test_utils .new_validate_billable_pi_processor ()
297
+ output_data = validate_billable_pi_proc ._validate_pi_names (test_data )
298
+ self .assertEqual (0 , len (output_data [pandas .isna (output_data ["Manager (PI)" ])]))
299
+
300
+
281
301
class TestMonthUtils (TestCase ):
282
302
def test_get_month_diff (self ):
283
303
testcases = [
@@ -707,31 +727,6 @@ def test_apply_BU_subsidy(self):
707
727
self .assertEqual (50 , output_df .loc [3 , "Balance" ])
708
728
709
729
710
- class TestValidateBillables (TestCase ):
711
- def setUp (self ):
712
- data = {
713
- "Manager (PI)" : ["PI1" , math .nan , "PI1" , "PI2" , "PI2" ],
714
- "Project - Allocation" : [
715
- "ProjectA" ,
716
- "ProjectB" ,
717
- "ProjectC" ,
718
- "ProjectD" ,
719
- "ProjectE" ,
720
- ],
721
- }
722
- self .dataframe = pandas .DataFrame (data )
723
-
724
- def test_validate_billables (self ):
725
- self .assertEqual (
726
- 1 , len (self .dataframe [pandas .isna (self .dataframe ["Manager (PI)" ])])
727
- )
728
- test_invoice = test_utils .new_billable_invoice ()
729
- validated_df = test_invoice ._validate_pi_names (self .dataframe )
730
- self .assertEqual (
731
- 0 , len (validated_df [pandas .isna (validated_df ["Manager (PI)" ])])
732
- )
733
-
734
-
735
730
class TestExportLenovo (TestCase ):
736
731
def setUp (self ):
737
732
data = {
0 commit comments