Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def to_ftp(self, output_path, file_name, host, username, password):
- """Upload file to FTP server."""
- ftp = ftplib.FTP(host)
- ftp.login(username, password)
- full_path = os.path.join(output_path, file_name)
- with open(full_path, "r") as ftp_file:
- ftp.storbinary(" ".join(["STOR", file_name]), ftp_file.read)
- @patch("ppc_model.io.ftplib.FTP")
- def test_store_call(self, mock_ftp):
- """The *storbinary* call must use the right arguments."""
- with patch("ppc_model.io.open", mock_open(read_data=None)) as m:
- self.writer.to_ftp(output_path="./output", file_name="output.zip",
- host="myftp", username="username", password="password")
- mock_ftp.return_value.storbinary.assert_called_once_with(
- "STOR output.zip", m.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement