# Path: minette/serializer.py
# class Serializable:
#     """
#     Base class for serializable object
# 
#     """
# 
#     @classmethod
#     def _types(cls):
#         """
#         Override this method to create instance of specific class for members.
#         Configure like below then instance of `Foo` will be set to `self.foo`
#         and `Bar` to `self.bar`
#         ```
#         return {
#             "foo": Foo,
#             "bar": Bar
#         }
#         ```
#         """
#         return {}
# 
#     def __repr__(self):
#         return "<{} at {}>\n{}".format(
#             self.__class__.__name__,
#             hex(id(self)),
#             self.to_json(indent=2, ensure_ascii=False))
# 
#     @classmethod
#     def create_object(obj_cls, d):
#         return obj_cls()
# 
#     def to_dict(self):
#         """
#         Convert this object to dict
# 
#         Returns
#         -------
#         d : dict
#             Object as dict
#         """
#         return dumpd(self)
# 
#     def to_json(self, **kwargs):
#         """
#         Convert this object to JSON
# 
#         Returns
#         -------
#         s : str
#             Object as JSON string
#         """
#         return dumps(self, **kwargs)
# 
#     @classmethod
#     def from_dict(cls, d):
#         """
#         Create object from dict
# 
#         Parameters
#         ----------
#         d : dict
#             Dictionary of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loadd(d, cls)
# 
#     @classmethod
#     def from_dict_dict(cls, dict_dict):
#         """
#         Create dictionary of this objects from dictionaries of dictionaries
# 
#         Parameters
#         ----------
#         dict_dict : dict
#             Dictionary of dictionaries
# 
#         Returns
#         -------
#         dict_of_this_obj : dict
#             Dictionary of this objects
#         """
#         return {k: cls.from_dict(v) for k, v in dict_dict.items()}
# 
#     @classmethod
#     def from_json(cls, s, **kwargs):
#         """
#         Create this object from JSON string
# 
#         Parameters
#         ----------
#         s : str
#             JSON string of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loads(s, cls, **kwargs)
# 
# Path: minette/utils.py
# def date_to_str(dt, with_timezone=False):
#     """
#     Convert datetime to str
# 
#     Parameters
#     ----------
#     dt : datetime
#         datetime to convert
#     with_timezone : bool, default False
#         Include timezone or not
# 
#     Returns
#     -------
#     datetime_str : str
#         Datetime string
#     """
#     if with_timezone and dt.tzinfo:
#         dtstr = dt.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
#         return dtstr[:-2] + ":" + dtstr[-2:]
#     else:
#         return dt.strftime("%Y-%m-%dT%H:%M:%S.%f")


import pytest
from pytz import timezone
from datetime import datetime
from minette.serializer import Serializable
from minette.utils import date_to_str
        },
        "cc2": {
            "strvalue": "str_2",
        },
    }
    cc = CustomClass.from_dict_dict(cc_dict_dict)
    assert cc["cc1"].strvalue == "str_1"
    assert cc["cc1"].to_dict() == CustomClass.from_dict({"strvalue": "str_1"}).to_dict()
    assert cc["cc2"].strvalue == "str_2"
    assert cc["cc2"].to_dict() == CustomClass.from_dict({"strvalue": "str_2"}).to_dict()


def test_from_dict_list():
    cc_dict_list = [
        {
            "strvalue": "str_1",
        },
        {
            "strvalue": "str_2",
        },
    ]
    cc = CustomClass.from_dict(cc_dict_list)
    assert cc[0].strvalue == "str_1"
    assert cc[0].to_dict() == CustomClass.from_dict({"strvalue": "str_1"}).to_dict()
    assert cc[1].strvalue == "str_2"
    assert cc[1].to_dict() == CustomClass.from_dict({"strvalue": "str_2"}).to_dict()


def test_from_json():
    now = datetime.now(timezone("Asia/Tokyo"))

# Path: minette/serializer.py
# class Serializable:
#     """
#     Base class for serializable object
# 
#     """
# 
#     @classmethod
#     def _types(cls):
#         """
#         Override this method to create instance of specific class for members.
#         Configure like below then instance of `Foo` will be set to `self.foo`
#         and `Bar` to `self.bar`
#         ```
#         return {
#             "foo": Foo,
#             "bar": Bar
#         }
#         ```
#         """
#         return {}
# 
#     def __repr__(self):
#         return "<{} at {}>\n{}".format(
#             self.__class__.__name__,
#             hex(id(self)),
#             self.to_json(indent=2, ensure_ascii=False))
# 
#     @classmethod
#     def create_object(obj_cls, d):
#         return obj_cls()
# 
#     def to_dict(self):
#         """
#         Convert this object to dict
# 
#         Returns
#         -------
#         d : dict
#             Object as dict
#         """
#         return dumpd(self)
# 
#     def to_json(self, **kwargs):
#         """
#         Convert this object to JSON
# 
#         Returns
#         -------
#         s : str
#             Object as JSON string
#         """
#         return dumps(self, **kwargs)
# 
#     @classmethod
#     def from_dict(cls, d):
#         """
#         Create object from dict
# 
#         Parameters
#         ----------
#         d : dict
#             Dictionary of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loadd(d, cls)
# 
#     @classmethod
#     def from_dict_dict(cls, dict_dict):
#         """
#         Create dictionary of this objects from dictionaries of dictionaries
# 
#         Parameters
#         ----------
#         dict_dict : dict
#             Dictionary of dictionaries
# 
#         Returns
#         -------
#         dict_of_this_obj : dict
#             Dictionary of this objects
#         """
#         return {k: cls.from_dict(v) for k, v in dict_dict.items()}
# 
#     @classmethod
#     def from_json(cls, s, **kwargs):
#         """
#         Create this object from JSON string
# 
#         Parameters
#         ----------
#         s : str
#             JSON string of this object
# 
#         Returns
#         -------
#         obj : Serializable
#             Instance of this class
#         """
#         return loads(s, cls, **kwargs)
# 
# Path: minette/utils.py
# def date_to_str(dt, with_timezone=False):
#     """
#     Convert datetime to str
# 
#     Parameters
#     ----------
#     dt : datetime
#         datetime to convert
#     with_timezone : bool, default False
#         Include timezone or not
# 
#     Returns
#     -------
#     datetime_str : str
#         Datetime string
#     """
#     if with_timezone and dt.tzinfo:
#         dtstr = dt.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
#         return dtstr[:-2] + ":" + dtstr[-2:]
#     else:
#         return dt.strftime("%Y-%m-%dT%H:%M:%S.%f")


# Path: tests/models/test_models_base.py
import pytest
from pytz import timezone
from datetime import datetime
from minette.serializer import Serializable
from minette.utils import date_to_str

        },
        "cc2": {
            "strvalue": "str_2",
        },
    }
    cc = CustomClass.from_dict_dict(cc_dict_dict)
    assert cc["cc1"].strvalue == "str_1"
    assert cc["cc1"].to_dict() == CustomClass.from_dict({"strvalue": "str_1"}).to_dict()
    assert cc["cc2"].strvalue == "str_2"
    assert cc["cc2"].to_dict() == CustomClass.from_dict({"strvalue": "str_2"}).to_dict()


def test_from_dict_list():
    cc_dict_list = [
        {
            "strvalue": "str_1",
        },
        {
            "strvalue": "str_2",
        },
    ]
    cc = CustomClass.from_dict(cc_dict_list)
    assert cc[0].strvalue == "str_1"
    assert cc[0].to_dict() == CustomClass.from_dict({"strvalue": "str_1"}).to_dict()
    assert cc[1].strvalue == "str_2"
    assert cc[1].to_dict() == CustomClass.from_dict({"strvalue": "str_2"}).to_dict()


def test_from_json():
    now = datetime.now(timezone("Asia/Tokyo"))

    cc_json = '{"strvalue": "str", "intvalue": 1, "dtvalue": "' + date_to_str(now, with_timezone=True) + '", "listvalue": [1, 2, 3], "dictvalue": {"key1": "value1", "key2": 2}, "objvalue": null}'