Skip to content
Snippets Groups Projects
Commit 6d733c76 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

API: Rename enum_converter to string_in_list

parent 4e3145e7
No related branches found
No related tags found
1 merge request!22Release 0.3
Pipeline #14714 failed
......@@ -29,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Proof-of-concept integration with Bloxberg.
- Introduce a cfood that can create a Record structure based on the contents of a hdf5 file
h5py is now an optional dependency
- enum_converter for table imports
- string-in-list check for table imports
### Changed ###
......
......@@ -145,7 +145,7 @@ def win_path_converter(val):
return path.as_posix()
def enum_converter(val, options, ignore_case=True):
def string_in_list(val, options, ignore_case=True):
"""Return the given value if it is contained in options, raise an
error otherwise.
......
......@@ -33,7 +33,7 @@ from caosadvancedtools.table_importer import (XLSImporter, assure_name_format,
incomplete_date_converter,
win_path_converter,
win_path_list_converter,
enum_converter,
string_in_list,
yes_no_converter)
......@@ -50,14 +50,15 @@ class ConverterTest(unittest.TestCase):
self.assertRaises(ValueError, yes_no_converter, "True")
self.assertRaises(ValueError, yes_no_converter, "true")
def test_enum(self):
self.assertEqual("false", enum_converter("false",
def test_string_in_list(self):
self.assertEqual("false", string_in_list("false",
["FALSE", "TRUE"]))
self.assertEqual("FALSE", enum_converter("FALSE",
self.assertEqual("FALSE", string_in_list("FALSE",
["FALSE", "TRUE"], False))
self.assertRaises(ValueError, enum_converter, "FALSE", [])
self.assertRaises(ValueError, enum_converter, "FALSE", ["fals"])
self.assertRaises(ValueError, enum_converter, "FALSE", ["false"], False)
self.assertRaises(ValueError, string_in_list, "FALSE", [])
self.assertRaises(ValueError, string_in_list, "FALSE", ["fals"])
self.assertRaises(ValueError, string_in_list,
"FALSE", ["false"], False)
def test_assure_name_format(self):
self.assertEqual(assure_name_format("Müstermann, Max"),
......@@ -72,7 +73,7 @@ class ConverterTest(unittest.TestCase):
["/this/computer"])
self.assertEqual(win_path_list_converter(
r"\this\computer,\this\computer"),
["/this/computer", "/this/computer"])
["/this/computer", "/this/computer"])
def test_datetime(self):
test_file = os.path.join(os.path.dirname(__file__), "date.xlsx")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment