diff --git a/refit/src/modules/librefit.py b/refit/src/modules/librefit.py index 5254182..8e57b40 100644 --- a/refit/src/modules/librefit.py +++ b/refit/src/modules/librefit.py @@ -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 diff --git a/refit/src/modules/test_librefit.py b/refit/src/modules/test_librefit.py new file mode 100644 index 0000000..ae0d05a --- /dev/null +++ b/refit/src/modules/test_librefit.py @@ -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 \ No newline at end of file