from typing import Type
import omni.kit.test

import omni.kit.capture.capture_options as _capture_options


class TestCaptureOptions(omni.kit.test.AsyncTestCase):

    async def test_capture_options_serialisation(self):
        options = _capture_options.CaptureOptions()
        data_dict = options.to_dict()

        self.assertIsInstance(data_dict, dict)

    async def test_capture_options_deserialisation(self):
        options = _capture_options.CaptureOptions()
        data_dict = options.to_dict()
        regenerated_options = _capture_options.CaptureOptions.from_dict(data_dict)

        self.assertIsInstance(regenerated_options, _capture_options.CaptureOptions)

    async def test_capture_options_values_persisted(self):
        options = _capture_options.CaptureOptions(camera="my_camera")
        data_dict = options.to_dict()
        regenerated_options = _capture_options.CaptureOptions.from_dict(data_dict)

        self.assertEqual(regenerated_options.camera, "my_camera")

    async def test_adding_random_attribute_fails(self):
        """ Test that adding new attributes without making them configurable via the __init__ will raise an exception
        """
        options = _capture_options.CaptureOptions()
        options._my_new_value = "foo"
        data_dict = options.to_dict()
        with self.assertRaises(TypeError, msg="__init__() got an unexpected keyword argument 'my_new_value'"):
            regnerated = _capture_options.CaptureOptions.from_dict(data_dict)