@@ -182,12 +182,13 @@ def setUp(self):
182
182
183
183
def test_export_pi (self ):
184
184
output_dir = tempfile .TemporaryDirectory ()
185
- process_report . export_pi_billables (
186
- self . dataframe , output_dir .name , self .invoice_month
185
+ pi_inv = test_utils . new_pi_specific_invoice (
186
+ output_dir .name , invoice_month = self .invoice_month , data = self . dataframe
187
187
)
188
-
189
- pi_csv_1 = f'{ self .dataframe ["Institution" ][0 ]} _{ self .dataframe ["Manager (PI)" ][0 ]} _{ self .dataframe ["Invoice Month" ][0 ]} .csv'
190
- pi_csv_2 = f'{ self .dataframe ["Institution" ][3 ]} _{ self .dataframe ["Manager (PI)" ][3 ]} _{ self .dataframe ["Invoice Month" ][3 ]} .csv'
188
+ pi_inv .process ()
189
+ pi_inv .export ()
190
+ pi_csv_1 = f'{ self .dataframe ["Institution" ][0 ]} _{ self .dataframe ["Manager (PI)" ][0 ]} { self .dataframe ["Invoice Month" ][0 ]} .csv'
191
+ pi_csv_2 = f'{ self .dataframe ["Institution" ][3 ]} _{ self .dataframe ["Manager (PI)" ][3 ]} { self .dataframe ["Invoice Month" ][3 ]} .csv'
191
192
self .assertIn (pi_csv_1 , os .listdir (output_dir .name ))
192
193
self .assertIn (pi_csv_2 , os .listdir (output_dir .name ))
193
194
self .assertEqual (
@@ -789,32 +790,46 @@ def test_process_lenovo(self):
789
790
790
791
class TestUploadToS3 (TestCase ):
791
792
@mock .patch ("process_report.process_report.get_invoice_bucket" )
792
- @mock .patch ("process_report.process_report .get_iso8601_time" )
793
- def test_remove_prefix (self , mock_get_time , mock_get_bucket ):
793
+ @mock .patch ("process_report.util .get_iso8601_time" )
794
+ def test_upload_to_s3 (self , mock_get_time , mock_get_bucket ):
794
795
mock_bucket = mock .MagicMock ()
795
796
mock_get_bucket .return_value = mock_bucket
796
797
mock_get_time .return_value = "0"
797
798
798
799
invoice_month = "2024-03"
799
- filenames = ["test.csv" , "test2.test.csv" , "test3" ]
800
+ filenames = ["test-test" , "test2.test" , "test3" ]
801
+ sample_base_invoice = test_utils .new_base_invoice (invoice_month = invoice_month )
802
+
800
803
answers = [
801
- ("test.csv" , f"Invoices/{ invoice_month } /test { invoice_month } .csv" ),
802
804
(
803
- "test.csv" ,
804
- f"Invoices/{ invoice_month } /Archive/ test { invoice_month } 0 .csv" ,
805
+ f "test-test { invoice_month } .csv" ,
806
+ f"Invoices/{ invoice_month } /test-test { invoice_month } .csv" ,
805
807
),
806
808
(
807
- "test2.test.csv" ,
809
+ f"test-test { invoice_month } .csv" ,
810
+ f"Invoices/{ invoice_month } /Archive/test-test { invoice_month } 0.csv" ,
811
+ ),
812
+ (
813
+ f"test2.test { invoice_month } .csv" ,
808
814
f"Invoices/{ invoice_month } /test2.test { invoice_month } .csv" ,
809
815
),
810
816
(
811
- "test2.test.csv" ,
817
+ f "test2.test { invoice_month } .csv" ,
812
818
f"Invoices/{ invoice_month } /Archive/test2.test { invoice_month } 0.csv" ,
813
819
),
814
- ("test3" , f"Invoices/{ invoice_month } /test3 { invoice_month } .csv" ),
815
- ("test3" , f"Invoices/{ invoice_month } /Archive/test3 { invoice_month } 0.csv" ),
820
+ (
821
+ f"test3 { invoice_month } .csv" ,
822
+ f"Invoices/{ invoice_month } /test3 { invoice_month } .csv" ,
823
+ ),
824
+ (
825
+ f"test3 { invoice_month } .csv" ,
826
+ f"Invoices/{ invoice_month } /Archive/test3 { invoice_month } 0.csv" ,
827
+ ),
816
828
]
817
829
818
- process_report .upload_to_s3 (filenames , invoice_month )
830
+ for filename in filenames :
831
+ sample_base_invoice .name = filename
832
+ sample_base_invoice .export_s3 (mock_bucket )
833
+
819
834
for i , call_args in enumerate (mock_bucket .upload_file .call_args_list ):
820
835
self .assertTrue (answers [i ] in call_args )
0 commit comments