From a68027bb9f7c11e1be3970d8a6aa94002db7a157 Mon Sep 17 00:00:00 2001 From: Y_SAKAI Date: Thu, 4 Aug 2022 15:33:31 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20json=5Fparser=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E5=87=A6=E7=90=86=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/parser/test_json_parse.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ecs/crm-datafetch/tests/parser/test_json_parse.py diff --git a/ecs/crm-datafetch/tests/parser/test_json_parse.py b/ecs/crm-datafetch/tests/parser/test_json_parse.py new file mode 100644 index 00000000..fe2c96ea --- /dev/null +++ b/ecs/crm-datafetch/tests/parser/test_json_parse.py @@ -0,0 +1,43 @@ +from src.parser.json_parse import JsonParser + + +class TestJsonParser(): + + def test_parse(self) -> dict: + """ + Cases: + - コメントアウトが記載されているJSONからコメントを取り除き、辞書型を返すこと + Arranges: + - JSON文字列を準備する + Expects: + - json.loadsされたファイルの内容が期待値と一致する + """ + + # Arranges + json_string = """{ + "aaaa": "aaaa", + # これはコメントです + "#これはコメントではありません": "#これはコメントではありません", + "bbb": false, + "hogehoge": [ + "ccc", + /これはコメントです + "/これはコメントではありません" + ] + }""" + + sut = JsonParser(json_string) + actual = sut.parse() + + # Expects + expected_value = { + "aaaa": "aaaa", + "#これはコメントではありません": "#これはコメントではありません", + "bbb": False, + "hogehoge": [ + "ccc", + "/これはコメントではありません" + ] + } + + assert actual == expected_value