From 66b7677a4cb163d0d87afd7f63b13b7c7332ce05 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal <59223300+nikhilbadyal@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:27:18 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Test=20click=20method=20(#25)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/click/__init__.py | 1 + test/click/click_test.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/click/__init__.py create mode 100644 test/click/click_test.py diff --git a/test/click/__init__.py b/test/click/__init__.py new file mode 100644 index 0000000..535fe34 --- /dev/null +++ b/test/click/__init__.py @@ -0,0 +1 @@ +"""Click tests.""" diff --git a/test/click/click_test.py b/test/click/click_test.py new file mode 100644 index 0000000..d3d2fd5 --- /dev/null +++ b/test/click/click_test.py @@ -0,0 +1,24 @@ +"""Click test cases.""" +import json + +from typing_extensions import Self + +from src.click_opt.cli_options import CliOptions + + +class TestClick: + """Test clock option.""" + + @staticmethod + def is_json(myjson: str) -> bool: + """Check if a string is json.""" + try: + json.loads(myjson) + except ValueError: + return False + return True + + def test_str_method_print_json(self: Self, cli_options: CliOptions) -> None: + """Test str method print json.""" + str_method = str(cli_options) + assert TestClick.is_json(str_method) is True