added gewt_default_file_name() and wrote tests
This commit is contained in:
@@ -33,3 +33,27 @@ def get_standard_folder_name(name):
|
||||
logger.debug("Continuing with expected input")
|
||||
logger.debug("get_standard_folder_name() exit.")
|
||||
return standard_folder_name
|
||||
|
||||
def get_standard_file_name(name):
|
||||
"""Returns the default file name if none is provided."""
|
||||
|
||||
logger.debug("running get_standard_file_name()")
|
||||
|
||||
if name is None:
|
||||
logger.warning("No name assigned, continue with default")
|
||||
standard_file_name = "file"
|
||||
else:
|
||||
|
||||
if len(name) > 1:
|
||||
_NAMES_WARNING = f"{len(name)} names given, only one required.\nContinuing with '{name[0]}' as name."
|
||||
logger.warning(_NAMES_WARNING)
|
||||
print(_NAMES_WARNING)
|
||||
standard_file_name = name[0]
|
||||
|
||||
logger.debug(f"{standard_file_name}, Type: {type(standard_file_name)}")
|
||||
else:
|
||||
standard_file_name = name[0]
|
||||
logger.debug("Continuing with expected input")
|
||||
|
||||
logger.debug("exiting get_standard_file_name()")
|
||||
return standard_file_name
|
||||
|
||||
16
refit/src/modules/test_librefit.py
Normal file
16
refit/src/modules/test_librefit.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import librefit
|
||||
|
||||
def test_get_default_file_name():
|
||||
"""Tests if the function returns the correct value"""
|
||||
default_name = librefit.get_standard_file_name()
|
||||
assert "file" in default_name
|
||||
|
||||
def test_get_default_folder_name():
|
||||
"""Test if the default directory name gets returned"""
|
||||
default_name = librefit.get_standard_folder_name()
|
||||
assert "directory" in default_name
|
||||
|
||||
def test_get_standard_name_number():
|
||||
"""Tests if the number function returns the correctly formatted string."""
|
||||
name_number = librefit.get_standard_name_number(20,3)
|
||||
assert "020" in name_number
|
||||
Reference in New Issue
Block a user