From bf5fedbfa3c1fb34b6cb77286035a9cbadec4bd9 Mon Sep 17 00:00:00 2001 From: Y_SAKAI Date: Thu, 4 Aug 2022 18:17:47 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=95=B0=E5=B8=B8=E7=B3=BB=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=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 | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/ecs/crm-datafetch/tests/parser/test_json_parse.py b/ecs/crm-datafetch/tests/parser/test_json_parse.py index fe2c96ea..1991aa54 100644 --- a/ecs/crm-datafetch/tests/parser/test_json_parse.py +++ b/ecs/crm-datafetch/tests/parser/test_json_parse.py @@ -1,3 +1,4 @@ +import pytest from src.parser.json_parse import JsonParser @@ -26,6 +27,7 @@ class TestJsonParser(): ] }""" + # Act sut = JsonParser(json_string) actual = sut.parse() @@ -41,3 +43,35 @@ class TestJsonParser(): } assert actual == expected_value + + def test_raise_parse(self) -> dict: + """ + Cases: + - コメントアウト記号ではない文字をコメントアウトとしたときに、例外が発生すること + Arranges: + - JSON文字列を準備する + Expects: + - 例外が発生し期待値と一致する + """ + + # Arranges + json_string = """{ + "aaaa": "aaaa", + $ これはコメントです + "#これはコメントではありません": "#これはコメントではありません", + "bbb": false, + "hogehoge": [ + "ccc", + /これはコメントです + "/これはコメントではありません" + ] + }""" + + # Act + with pytest.raises(Exception) as e: + + sut = JsonParser(json_string) + sut.parse() + + # Expects + assert str(e.value) == "Expecting property name enclosed in double quotes: line 3 column 13 (char 42)"