Skip to content

Commit

Permalink
corrected test
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Mar 20, 2024
1 parent d827c77 commit 2f533a7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/unit/test_ftp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ftplib
import os
from pathlib import Path
import unittest
from ftplib import error_perm
from pathlib import Path
from unittest.mock import MagicMock, patch

from kghub_downloader.download_utils import (
Expand Down Expand Up @@ -71,7 +71,9 @@ def test_is_matching_filename(self):
# Test with no pattern provided (should always return True)
self.assertTrue(is_matching_filename("file.jpg", None))

@unittest.skipIf(os.getenv('GITHUB_ACTIONS') == 'true', "This test needs credentials to run.")
@unittest.skipIf(
os.getenv("GITHUB_ACTIONS") == "true", "This test needs credentials to run."
)
def test_actual_upload_download(self):
# Credentials available at: https://dlptest.com/ftp-test/
pwd = Path.cwd()
Expand All @@ -81,11 +83,11 @@ def test_actual_upload_download(self):
ftp = ftplib.FTP("ftp.dlptest.com")
ftp.login(os.environ["FTP_USERNAME"], os.environ["FTP_PASSWORD"])
# upload the file ../resources/test_file.txt to the server
ftp.storbinary("STOR test_file.txt", open(f"{resources_dir}/testfile.txt", "rb"))
ftp.storbinary(
"STOR test_file.txt", open(f"{resources_dir}/testfile.txt", "rb")
)
# download the file test_file.txt from the server
with open(f"{output_dir}/test_file.txt", "wb") as f:
ftp.retrbinary("RETR test_file.txt", f.write)
ftp.quit()
download_via_ftp(ftp, "/", f"{output_dir}", "*.txt")
# Check that the file was downloaded correctly
self.assertTrue(os.path.exists(f"{output_dir}/test_file.txt"))
os.remove(f"{output_dir}/test_file.txt")

0 comments on commit 2f533a7

Please sign in to comment.