import unittest
from datetime import datetime

from ecmind_blue_client import MainTypeId
from ecmind_blue_client.ecm.builder import DmsDataBuilder


class TestQueryBuilder(unittest.TestCase):

    def test_data_builder(self):

        with DmsDataBuilder() as b:
            with b.object("Unittest_DMS_Document") as o:
                o.search_field("Name", "Server-API")
                o.field("Name", "Server-API")
                o.folder_id = 347
                o.maintype = MainTypeId.DOC_WINDOWS
                o.register_id = 350
                with o.table_field("TableField") as t:
                    t.row({"TableCol1": "Row1", "TableCol2": "42", "TableCol3": datetime.now(), "TableCol4": 3.5672}, 1)

                o.remark_object(347, 4, "INSERT", "test 1", "BLUE")
                o.remark_text(1234, "INSERT", "test 2", "YELLOW")

            xml = b.to_xml().decode("UTF-8")

            print(xml)


if __name__ == "__main__":
    unittest.main()
