aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-08-01 11:53:56 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2020-08-01 11:53:56 -0500
commitb1c23487c33fc2ad5503b6340b17980a326918c8 (patch)
treedb8fa8f1147ddcdd0df072431cfdb37e24976a1c /tests
parentAdd '-E yaml -E toml' to install instructions (diff)
downloadconfig-file-b1c23487c33fc2ad5503b6340b17980a326918c8.zip
Lint files
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config_file.py41
-rw-r--r--tests/test_custom_parser_with_config_file.py31
-rw-r--r--tests/test_ini_parser.py2
-rw-r--r--tests/test_json_parser.py13
4 files changed, 41 insertions, 46 deletions
diff --git a/tests/test_config_file.py b/tests/test_config_file.py
index 6718a94..d655397 100644
--- a/tests/test_config_file.py
+++ b/tests/test_config_file.py
@@ -169,9 +169,7 @@ def test_that_config_file_can_get(
assert ret_val == value
-@pytest.mark.parametrize(
- "key", ["header_one.number_key", "header_one"]
-)
+@pytest.mark.parametrize("key", ["header_one.number_key", "header_one"])
def test_that_config_file_can_delete(templated_config_file, key):
config = templated_config_file()
@@ -180,9 +178,7 @@ def test_that_config_file_can_delete(templated_config_file, key):
assert config.has(key) is False
-@pytest.mark.parametrize(
- "key", ["", 0, False, {}, "header_one.does_not_exist"]
-)
+@pytest.mark.parametrize("key", ["", 0, False, {}, "header_one.does_not_exist"])
def test_that_config_file_raises_missing_key_error_on_invalid_input_or_missing_key(
templated_config_file, key
):
@@ -190,36 +186,3 @@ def test_that_config_file_raises_missing_key_error_on_invalid_input_or_missing_k
with pytest.raises(MissingKeyError):
config.delete(key)
-
-
-# def test_that_custom_parser_can_be_used(template_and_config_file):
-# class CustomParser(AbstractParser):
-# def __init__(self, file_contents):
-# super().__init__(file_contents)
-#
-# def parse(self, file_contents: str):
-# return file_contents
-#
-# def get(self, key, parse_types=True):
-# return key
-#
-# def set(self, key, value):
-# return key, value
-#
-# def delete(self, section_key):
-# return section_key
-#
-# def has(self, section_key: str) -> bool:
-# return True
-#
-# def stringify(self) -> str:
-# return str(self.parsed_content)
-#
-# template_file, config = template_and_config_file(parser=CustomParser)
-#
-# assert isinstance(config._ConfigFile__parser, CustomParser)
-# assert config.get("key") == "key"
-# assert config.set("key", "value") == ("key", "value")
-# assert config.delete("section_key") == "section_key"
-# assert config.has("blah")
-# assert config.stringify() == template_file.read_text()
diff --git a/tests/test_custom_parser_with_config_file.py b/tests/test_custom_parser_with_config_file.py
new file mode 100644
index 0000000..3c8bf98
--- /dev/null
+++ b/tests/test_custom_parser_with_config_file.py
@@ -0,0 +1,31 @@
+# def test_that_custom_parser_can_be_used(template_and_config_file):
+# class CustomParser(AbstractParser):
+# def __init__(self, file_contents):
+# super().__init__(file_contents)
+#
+# def parse(self, file_contents: str):
+# return file_contents
+#
+# def get(self, key, parse_types=True):
+# return key
+#
+# def set(self, key, value):
+# return key, value
+#
+# def delete(self, section_key):
+# return section_key
+#
+# def has(self, section_key: str) -> bool:
+# return True
+#
+# def stringify(self) -> str:
+# return str(self.parsed_content)
+#
+# template_file, config = template_and_config_file(parser=CustomParser)
+#
+# assert isinstance(config._ConfigFile__parser, CustomParser)
+# assert config.get("key") == "key"
+# assert config.set("key", "value") == ("key", "value")
+# assert config.delete("section_key") == "section_key"
+# assert config.has("blah")
+# assert config.stringify() == template_file.read_text()
diff --git a/tests/test_ini_parser.py b/tests/test_ini_parser.py
index 45e82c3..46966c9 100644
--- a/tests/test_ini_parser.py
+++ b/tests/test_ini_parser.py
@@ -1,6 +1,6 @@
import pytest
-from config_file.exceptions import ParsingError, MissingKeyError
+from config_file.exceptions import MissingKeyError, ParsingError
from config_file.parsers.ini_parser import IniParser
diff --git a/tests/test_json_parser.py b/tests/test_json_parser.py
index 514a640..f8200b0 100644
--- a/tests/test_json_parser.py
+++ b/tests/test_json_parser.py
@@ -1,9 +1,6 @@
-import json
-
import pytest
from config_file.exceptions import ParsingError
-from config_file.parsers.json_parser import JsonParser
def test_invalid_json(templated_parser):
@@ -45,8 +42,8 @@ def test_that_json_parser_can_find_wild_keys(key, templated_parser):
[
"glossary",
"glossary.title",
- "glossary.GlossDiv.GlossList.GlossEntry.GlossDef.para"
- ]
+ "glossary.GlossDiv.GlossList.GlossEntry.GlossDef.para",
+ ],
)
def test_that_json_parser_can_find_dot_keys(key, templated_parser):
parser = templated_parser("json", "glossary")
@@ -98,7 +95,11 @@ def test_that_json_parser_can_set_keys(templated_parser, key, value):
@pytest.mark.parametrize(
"key",
- ["glossary", "glossary.dict_within_dict", "glossary.GlossDiv.GlossList.GlossEntry.Abbrev"],
+ [
+ "glossary",
+ "glossary.dict_within_dict",
+ "glossary.GlossDiv.GlossList.GlossEntry.Abbrev",
+ ],
)
def test_that_json_parser_can_delete_keys(template_and_parser, key):
template, parser = template_and_parser("json", "glossary")