Get files in local directory

This commit is contained in:
The Magician 2023-10-20 18:38:21 +01:00
parent 68d37afec7
commit eac6deee1d
2 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys import os, sys
import bs4 import bs4
@ -48,6 +48,9 @@ def get_garden_filenames(browser):
return titles return titles
def get_local_filenames(directory):
return os.listdir(directory)
def main(email, password): def main(email, password):
browser = initialize_webdriver() browser = initialize_webdriver()
navigate_to_filegarden(browser) navigate_to_filegarden(browser)

View File

@ -114,6 +114,17 @@ class TestJardin(unittest.TestCase):
self.assertEqual(filenames, ["file1.jpg", "file2.jpg"]) self.assertEqual(filenames, ["file1.jpg", "file2.jpg"])
@patch("jardin.os.listdir")
def test_get_local_filenames_gets_filenames_in_local_directory(self, mockListdir):
mockDirectory = "/home/luser/gardenfiles/"
mockFiles = ["file1", "file2", "file3"]
mockListdir.return_value = mockFiles
localFiles = jardin.get_local_filenames(mockDirectory)
mockListdir.assert_called_once_with(mockDirectory)
self.assertEqual(localFiles, mockFiles)
@patch("jardin.initialize_webdriver") @patch("jardin.initialize_webdriver")
@patch("jardin.navigate_to_filegarden") @patch("jardin.navigate_to_filegarden")
@patch("jardin.login_with_password") @patch("jardin.login_with_password")