From df765605ad8295776e710afd305f848813ab0e43 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sun, 2 Feb 2020 14:32:59 -0600 Subject: Add working JSON parser --- tests/test_config_file.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/test_config_file.py') 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( -- cgit v1.2.3