# Path: rwslib/tests/common.py
# def obj_to_doc(obj, *args, **kwargs):
#     """Convert an object to am XML document object
#     :rtype: xml.etree.ElementTree.Element
#     """
#     builder = ET.TreeBuilder()
#     obj.build(builder, *args, **kwargs)
#     return builder.close()


import unittest
from rwslib.builders import *
from rwslib.tests.common import obj_to_doc
from datetime import datetime
    """Test ClinicalData classes"""

    def setUp(self):
        self.tested = ClinicalData("STUDY1", "DEV")(
            SubjectData("SITE1", "SUBJECT1")(
                StudyEventData("VISIT_1")(
                    FormData("TESTFORM_A")(
                        ItemGroupData()(
                            ItemData("Field1", "ValueA"), ItemData("Field2", "ValueB")
                        ),
                        ItemGroupData(item_group_repeat_key=2)(
                            ItemData("Field3", "ValueC")
                        ),
                    )
                )
            )
        )

    def test_basic(self):
        """Test there are 3 children"""
        self.assertEqual("STUDY1", self.tested.projectname)
        self.assertEqual("DEV", self.tested.environment)
        # Test default MetadataVersionOID
        self.assertEqual("1", self.tested.metadata_version_oid)

    def test_metadata_version_oid(self):
        """
        Test we can handle a MDV as a String
        """
        self.tested.metadata_version_oid = "2"

# Path: rwslib/tests/common.py
# def obj_to_doc(obj, *args, **kwargs):
#     """Convert an object to am XML document object
#     :rtype: xml.etree.ElementTree.Element
#     """
#     builder = ET.TreeBuilder()
#     obj.build(builder, *args, **kwargs)
#     return builder.close()


# Path: rwslib/tests/test_builders_clinicaldata.py
import unittest
from rwslib.builders import *
from rwslib.tests.common import obj_to_doc
from datetime import datetime

    """Test ClinicalData classes"""

    def setUp(self):
        self.tested = ClinicalData("STUDY1", "DEV")(
            SubjectData("SITE1", "SUBJECT1")(
                StudyEventData("VISIT_1")(
                    FormData("TESTFORM_A")(
                        ItemGroupData()(
                            ItemData("Field1", "ValueA"), ItemData("Field2", "ValueB")
                        ),
                        ItemGroupData(item_group_repeat_key=2)(
                            ItemData("Field3", "ValueC")
                        ),
                    )
                )
            )
        )

    def test_basic(self):
        """Test there are 3 children"""
        self.assertEqual("STUDY1", self.tested.projectname)
        self.assertEqual("DEV", self.tested.environment)
        # Test default MetadataVersionOID
        self.assertEqual("1", self.tested.metadata_version_oid)

    def test_metadata_version_oid(self):
        """
        Test we can handle a MDV as a String
        """
        self.tested.metadata_version_oid = "2"

        doc = obj_to_doc(self.tested)