import omni.kit.test
import omni.kit.app

from pathlib import Path

from .test_base import KitLaunchTest


class TestNonAsciiCmdParams(KitLaunchTest):
    async def test_kit_app_with_only_core_exts(self):
        # Disabling tests untill OM-39027 is resolved
        return

        kit_file = "[dependencies]\n"
        kit_file += '"omni.kit.loop-default" = {}\n'

        script = """
import carb.settings
import omni.kit.app
s = carb.settings.get_settings()
def check(path, expected):
    v = s.get(path)
    if v != expected:
        print(f"[Test Fail] setting path: {path}, expected: {expected}, got: {v}")
        omni.kit.app.get_app().post_quit(-1)

"""

        testParamPaths = ["/my/test/unicode_param", "/my/test/usual_param", "/my/test/unicode_param2"]
        testParamValues = ["\U0001F44D", "test", "\u0627\u1F600"]

        # Adding checks if unicode params were properly set into settings
        script += "".join(map(lambda x, y: f"check(\"{x}\", \"{y}\")\n", testParamPaths, testParamValues))

        # Making sure the executed script has proper unicode symbols
        script += f"""
test_unicode_char = \"{testParamValues[0]}\"
test_char_code = ord(test_unicode_char)
expected_code = 128077
if test_char_code != expected_code:
    print(f"[Test Fail] Wrong tested unicode character code: {{test_unicode_char}}, expected: {{expected_code}}, got: {{test_char_code}}")
    omni.kit.app.get_app().post_quit(-1)
"""

        # Adding necessary command line arguments
        additional_args = [*map(lambda x, y: f"--{x}={y}", testParamPaths, testParamValues)]

        await self._run_kit_with_script(script, args=["--/app/quitAfter=10", *additional_args], kit_file=kit_file)
