aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_config_file.py
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-02-02 14:32:59 -0600
committerEugene Triguba <eugenetriguba@gmail.com>2020-02-02 14:32:59 -0600
commitdf765605ad8295776e710afd305f848813ab0e43 (patch)
tree9d38205653c83dbba880572216e63b6524b12e95 /tests/test_config_file.py
parentAdd type hints + contents is now content in BaseParser (diff)
downloadconfig-file-df765605ad8295776e710afd305f848813ab0e43.zip
Add working JSON parser
Diffstat (limited to 'tests/test_config_file.py')
-rw-r--r--tests/test_config_file.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_config_file.py b/tests/test_config_file.py
index 0e42d19..f57bd69 100644
--- a/tests/test_config_file.py
+++ b/tests/test_config_file.py
@@ -1,3 +1,4 @@
+import json
from pathlib import Path
import pytest
@@ -91,6 +92,13 @@ def test_that_config_file_can_save(tmpdir, file_contents, file_name):
"config.ini",
"[calendar]\nsunday_index = 0\n\n",
),
+ (
+ "calendar.sunday_index",
+ 0,
+ False,
+ "config.json",
+ json.dumps({"calendar": {"sunday_index": 0}}),
+ ),
],
)
def test_that_config_file_can_get(
@@ -108,6 +116,9 @@ def test_that_config_file_can_get(
("ini", "[calendar]\nsunday_index = 0\n\n", "calendar.sunday_index", True),
("ini", "[calendar]\nsunday_index = 0\n\n", "calendar.blah", False),
("ini", "[calendar]\nsunday_index = 0\n\n", "calendar", True),
+ ("json", json.dumps({"calendar": {"sunday_index": 0}}), "calendar", True),
+ ("json", json.dumps({"calendar": {"sunday_index": 0}}), "blah", False),
+ ("json", json.dumps({"calendar": {"sunday_index": 0}}), "sunday_index", True),
],
)
def test_that_config_file_can_find_sections_and_keys(
@@ -128,6 +139,12 @@ def test_that_config_file_can_find_sections_and_keys(
"[calendar]\nsunday_index = 0\n\n",
"[calendar]\n\n",
),
+ (
+ "calendar.sunday_index",
+ "config.json",
+ json.dumps({"calendar": {"sunday_index": 0}}),
+ json.dumps({"calendar": {}}),
+ ),
],
)
def test_that_config_file_can_delete(