def _test_resource_serialization(self, session_method, resource_method):
        attr_type = resource.Resource

        class Test(resource.Resource):
            allow_create = True
            attr = resource.prop("attr", type=attr_type)

        the_id = 123
        sot = Test()
        sot.attr = resource.Resource({"id": the_id})
        self.assertEqual(attr_type, type(sot.attr))

        def fake_call(*args, **kwargs):
            attrs = kwargs["json"]
            try:
                json.dumps(attrs)
            except __HOLE__ as e:
                self.fail("Unable to serialize _attrs: %s" % e)
            resp = mock.Mock()
            resp.json = mock.Mock(return_value=attrs)
            return resp

        session = mock.Mock()
        setattr(session, session_method, mock.Mock(side_effect=fake_call))

        if resource_method == "create_by_id":
            session.create_by_id(session, sot._attrs)
        elif resource_method == "update_by_id":
            session.update_by_id(session, None, sot._attrs)
dataset/ETHPy150Open openstack/python-openstacksdk/openstack/tests/unit/test_resource.py/ResourceMapping._test_resource_serialization