File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 66import time
77from datetime import datetime
88import pdb
9+
10+ import mock
911import pandas as pd
1012
1113from delphi_nssp .pull import (
@@ -29,12 +31,20 @@ def test_get_source_data(self, params_w_patch):
2931 mock_sftp = MagicMock ()
3032 mock_sftp .stat = MagicMock ()
3133 mock_ssh .open_sftp .return_value = mock_sftp
34+
35+ source_path = params_w_patch ["common" ]["backup_dir" ]
36+ dest_path = params_w_patch ["patch" ]["source_dir" ]
37+
38+ dates = pd .date_range (params_w_patch ["patch" ]["start_issue" ], params_w_patch ["patch" ]["end_issue" ])
39+ files = [f"{ date .strftime ('%Y%m%d' )} .csv.gz" for date in dates ]
40+
3241 with patch ("paramiko.SSHClient" , return_value = mock_ssh ):
33- get_source_data (params , logger )
42+ get_source_data (params_w_patch , logger )
3443
35- mock_sftp .chdir .assert_called_once_with ("/test_backup_dir" )
36- assert mock_sftp .get .call_count == 3
44+ mock_sftp .chdir .assert_called_once_with (source_path )
3745
46+ for file in files :
47+ mock_sftp .get .has_calls (file , f"{ dest_path } /{ file } " , mock .ANY )
3848 @patch ("delphi_nssp.pull.Socrata" )
3949 def test_normal_pull_nssp_data (self , mock_socrata , params , caplog ):
4050 today = pd .Timestamp .today ().strftime ("%Y%m%d" )
You can’t perform that action at this time.
0 commit comments