Made it like an app
This commit is contained in:
parent
ac9627e435
commit
490be29faa
|
|
@ -17,6 +17,7 @@ classifiers =
|
|||
packages =
|
||||
criteriaSorter
|
||||
criteriaSorter.modules
|
||||
; criteriaSorter.criteriaSorter
|
||||
install_requires =
|
||||
pyyaml>=6.0
|
||||
python_requires = >=3.6
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
from criteriaSorter.modules import criteriaSorter
|
||||
import sys
|
||||
|
||||
|
||||
# pragma: nocover # The main call can't be covered because it will only execute through the CLI
|
||||
if __name__ == "__main__":
|
||||
criteriaSorter.main(sys.argv)
|
||||
sys.exit(0)
|
||||
|
|
@ -7,7 +7,7 @@ import os
|
|||
import time
|
||||
import rich
|
||||
from rich.logging import RichHandler
|
||||
from fileops import DirectoryHandler, FileHandler, ArtistHandler
|
||||
from criteriaSorter.modules.fileops import DirectoryHandler, FileHandler, ArtistHandler
|
||||
|
||||
|
||||
def action_sort(argsp):
|
||||
|
|
@ -191,6 +191,7 @@ def parse_args(argvp):
|
|||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def main(argvp):
|
||||
"""
|
||||
Main function
|
||||
|
|
@ -205,6 +206,3 @@ def main(argvp):
|
|||
# Execute the action
|
||||
_LIST_ACTIONS[args.action](args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
# Test file for fileops.py
|
||||
from criteriaSorter.modules import fileops
|
||||
|
||||
|
||||
def _mock_get_file_list(dir_path):
|
||||
# Mock function for testing
|
||||
return ["file1", "file2", "file3"]
|
||||
|
||||
|
||||
def _mock_get_file_list_with_size(dir_path):
|
||||
# Mock function for testing
|
||||
return [("file1", 1), ("file2", 2), ("file3", 3)]
|
||||
|
||||
|
||||
def test_DirectoryHandler():
|
||||
# Regular invocation
|
||||
handler = fileops.DirectoryHandler(".")
|
||||
|
||||
# Test regular calls, doen't test the return value
|
||||
handler.get_dir_path()
|
||||
handler.get_dir_name()
|
||||
handler.get_dir_size()
|
||||
handler.get_dir_size_in_mb()
|
||||
handler.get_dir_size_in_gb()
|
||||
[f for f in handler.get_files()]
|
||||
[f for f in handler.get_directories()]
|
||||
handler.get_file_list_with_size()
|
||||
|
||||
# Using a mock function to test return value
|
||||
handler = fileops.DirectoryHandler("/Test/Path")
|
||||
handler.get_file_list=_mock_get_file_list
|
||||
handler.get_file_list_with_size=_mock_get_file_list_with_size
|
||||
|
||||
# Test return values
|
||||
assert handler.get_dir_path() == "/Test/Path"
|
||||
assert handler.get_dir_name() == "Path"
|
||||
assert handler.get_dir_size() == 6
|
||||
assert handler.get_dir_size_in_mb() == 0.06
|
||||
assert handler.get_dir_size_in_gb() == 0.00006
|
||||
assert handler.get_files() == ["file1", "file2", "file3"]
|
||||
|
||||
|
||||
|
||||
# def test_FileHandler():
|
||||
# handler = fileops.FileHandler(".")
|
||||
#
|
||||
#
|
||||
# def test_ArticleHandler():
|
||||
# handler = fileops.ArtistHandler(".")
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
# Test file for fileops.py
|
||||
from criteriaSorter.modules import fileops
|
||||
|
||||
|
||||
def test_DirectoryHandler():
|
||||
handler = fileops.DirectoryHandler(".")
|
||||
|
||||
|
||||
def test_FileHandler():
|
||||
handler = fileops.FileHandler(".")
|
||||
|
||||
|
||||
def test_ArticleHandler():
|
||||
handler = fileops.ArtistHandler(".")
|
||||
Loading…
Reference in New Issue