33import glob
44from datetime import datetime
55from pathlib import Path
6- import shutil
76
87# third party
98import pandas as pd
@@ -49,32 +48,24 @@ def test_store_backfill_file(self):
4948 assert fn not in os .listdir (backfill_dir )
5049
5150 def test_merge_backfill_file (self ):
52-
53- today = datetime .today ()
54-
55- fn = "claims_hosp_from_20200611_to_20200614.parquet"
51+ fn = "claims_hosp_202006.parquet"
5652 assert fn not in os .listdir (backfill_dir )
5753
5854 # Check when there is no daily file to merge.
5955 today = datetime (2020 , 6 , 14 )
60- merge_backfill_file (backfill_dir , today . weekday (), today ,
61- test_mode = True , check_nd = 8 )
56+ merge_backfill_file (backfill_dir , today , TEST_LOGGER ,
57+ test_mode = True )
6258 assert fn not in os .listdir (backfill_dir )
6359
6460 # Generate backfill daily files
6561 for d in range (11 , 15 ):
6662 dropdate = datetime (2020 , 6 , d )
6763 store_backfill_file (DATA_FILEPATH , dropdate , backfill_dir )
6864
69- # Check the when the merged file is not generated
70- today = datetime (2020 , 6 , 14 )
71- merge_backfill_file (backfill_dir , today .weekday (), today ,
72- test_mode = True , check_nd = 8 )
73- assert fn not in os .listdir (backfill_dir )
74-
75- # Generate the merged file, but not delete it
76- merge_backfill_file (backfill_dir , today .weekday (), today ,
77- test_mode = True , check_nd = 2 )
65+ # Check when the merged file is not generated
66+ today = datetime (2020 , 7 , 1 )
67+ merge_backfill_file (backfill_dir , today , TEST_LOGGER ,
68+ test_mode = True )
7869 assert fn in os .listdir (backfill_dir )
7970
8071 # Read daily file
@@ -112,15 +103,15 @@ def prep_backfill_data():
112103
113104 today = datetime (2020 , 6 , 14 )
114105 # creating expected file
115- merge_backfill_file (backfill_dir , today . weekday (), today ,
116- test_mode = True , check_nd = 2 )
106+ merge_backfill_file (backfill_dir , today , TEST_LOGGER ,
107+ test_mode = True )
117108 original = f"{ backfill_dir } /claims_hosp_from_20200611_to_20200614.parquet"
118109 os .rename (original , f"{ backfill_dir } /expected.parquet" )
119110
120111 # creating backfill without issue date
121112 os .remove (f"{ backfill_dir } /claims_hosp_as_of_{ issue_date_str } .parquet" )
122113 today = datetime (2020 , 6 , 14 )
123- merge_backfill_file (backfill_dir , today . weekday (), today ,
114+ merge_backfill_file (backfill_dir , today ,
124115 test_mode = True , check_nd = 2 )
125116
126117 old_files = glob .glob (backfill_dir + "/claims_hosp_as_of_*" )
@@ -141,7 +132,7 @@ def prep_backfill_data():
141132
142133
143134 def test_merge_existing_backfill_files_no_call (self ):
144- issue_date = datetime (year = 2020 , month = 6 , day = 20 )
135+ issue_date = datetime (year = 2020 , month = 5 , day = 20 )
145136 issue_date_str = issue_date .strftime ("%Y%m%d" )
146137 def prep_backfill_data ():
147138 # Generate backfill daily files
@@ -151,8 +142,8 @@ def prep_backfill_data():
151142
152143 today = datetime (2020 , 6 , 14 )
153144 # creating expected file
154- merge_backfill_file (backfill_dir , today . weekday (), today ,
155- test_mode = True , check_nd = 8 )
145+ merge_backfill_file (backfill_dir , today , TEST_LOGGER ,
146+ test_mode = True )
156147
157148 prep_backfill_data ()
158149 file_to_add = store_backfill_file (DATA_FILEPATH , issue_date , backfill_dir )
0 commit comments