当前位置: 首页>>代码示例>>Python>>正文


Python Context.to_dict方法代码示例

本文整理汇总了Python中furious.context.Context.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Context.to_dict方法的具体用法?Python Context.to_dict怎么用?Python Context.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在furious.context.Context的用法示例。


在下文中一共展示了Context.to_dict方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_to_dict_with_callbacks

# 需要导入模块: from furious.context import Context [as 别名]
# 或者: from furious.context.Context import to_dict [as 别名]
    def test_to_dict_with_callbacks(self):
        """Ensure to_dict correctly encodes callbacks."""
        import copy

        from furious.async import Async
        from furious.context import Context

        options = {
            'persistence_engine': 'persistence_engine',
            'callbacks': {
                'success': self.__class__.test_to_dict_with_callbacks,
                'failure': "failure_function",
                'exec': Async(target=dir)
            }
        }

        context = Context(**copy.deepcopy(options))

        # This stuff gets dumped out by to_dict().
        options.update({
            'insert_tasks': 'furious.context.context._insert_tasks',
            'persistence_engine': 'persistence_engine',
            '_tasks_inserted': False,
            '_task_ids': [],
            'callbacks': {
                'success': ("furious.tests.context.test_context."
                            "TestContext.test_to_dict_with_callbacks"),
                'failure': "failure_function",
                'exec': {'job': ('dir', None, None),
                         '_recursion': {'current': 0, 'max': 100},
                         '_type': 'furious.async.Async'}
            }
        })

        self.assertEqual(options, context.to_dict())
开发者ID:dustinhiatt-wf,项目名称:furious,代码行数:37,代码来源:test_context.py

示例2: test_store_context

# 需要导入模块: from furious.context import Context [as 别名]
# 或者: from furious.context.Context import to_dict [as 别名]
 def test_store_context(self):
     from furious.extras.appengine.ndb_persistence import store_context
     from furious.extras.appengine.ndb_persistence import load_context
     from furious.extras.appengine.ndb_persistence import ContextPersist
     from furious.context import Context
     ctx = Context()
     ctx.add('test', args=[1, 2])
     ctx_dict = ctx.to_dict()
     store_context(ctx.id, ctx_dict)
     ctx_persisted = ContextPersist.get_by_id(ctx.id)
     self.assertIsNotNone(ctx_persisted)
     reloaded_ctx = load_context(ctx.id)
     self.assertEqual(reloaded_ctx, ctx_dict)
开发者ID:johnlockwood-wf,项目名称:furious,代码行数:15,代码来源:test_ndb_persistence.py

示例3: test_persist_persists

# 需要导入模块: from furious.context import Context [as 别名]
# 或者: from furious.context.Context import to_dict [as 别名]
    def test_persist_persists(self):
        """Calling persist with an engine persists the Context."""
        from furious.context import Context

        persistence_engine = Mock()
        persistence_engine.func_name = "persistence_engine"
        persistence_engine.im_class.__name__ = "engine"

        context = Context(persistence_engine=persistence_engine)

        context.persist()

        persistence_engine.store_context.assert_called_once_with(context.id, context.to_dict())
开发者ID:ericolson-wf,项目名称:furious,代码行数:15,代码来源:test_context.py

示例4: test_save_context

# 需要导入模块: from furious.context import Context [as 别名]
# 或者: from furious.context.Context import to_dict [as 别名]
    def test_save_context(self):
        """Ensure the passed in context gets serialized and set on the saved
        FuriousContext entity.
        """
        _id = "contextid"

        context = Context(id=_id)

        result = store_context(context)

        self.assertEqual(result.id(), _id)

        loaded_context = FuriousContext.from_id(result.id())

        self.assertEqual(context.to_dict(), loaded_context.to_dict())
开发者ID:brentarndorfer-wf,项目名称:furious,代码行数:17,代码来源:test_ndb_persistence.py

示例5: test_to_dict

# 需要导入模块: from furious.context import Context [as 别名]
# 或者: from furious.context.Context import to_dict [as 别名]
    def test_to_dict(self):
        """Ensure to_dict returns a dictionary representation of the Context.
        """
        import copy

        from furious.context import Context

        options = {"persistence_engine": "persistence_engine", "unkown": True}

        context = Context(**copy.deepcopy(options))

        # This stuff gets dumped out by to_dict().
        options.update(
            {"insert_tasks": "furious.context.context._insert_tasks", "_tasks_inserted": False, "_task_ids": []}
        )

        self.assertEqual(options, context.to_dict())
开发者ID:ericolson-wf,项目名称:furious,代码行数:19,代码来源:test_context.py

示例6: test_to_dict_with_callbacks

# 需要导入模块: from furious.context import Context [as 别名]
# 或者: from furious.context.Context import to_dict [as 别名]
    def test_to_dict_with_callbacks(self):
        """Ensure to_dict correctly encodes callbacks."""
        import copy

        from furious.async import Async
        from furious.context import Context

        options = {
            "id": "someid",
            "context_id": "contextid",
            "parent_id": "parentid",
            "persistence_engine": "persistence_engine",
            "callbacks": {
                "success": self.__class__.test_to_dict_with_callbacks,
                "failure": "failure_function",
                "exec": Async(target=dir, id="blargh", context_id="contextid", parent_id="parentid"),
            },
        }

        context = Context(**copy.deepcopy(options))

        # This stuff gets dumped out by to_dict().
        options.update(
            {
                "id": "someid",
                "insert_tasks": "furious.context.context._insert_tasks",
                "persistence_engine": "persistence_engine",
                "_tasks_inserted": False,
                "_task_ids": [],
                "callbacks": {
                    "success": ("furious.tests.context.test_context." "TestContext.test_to_dict_with_callbacks"),
                    "failure": "failure_function",
                    "exec": {
                        "job": ("dir", None, None),
                        "id": "blargh",
                        "context_id": "contextid",
                        "parent_id": "parentid",
                        "_recursion": {"current": 0, "max": 100},
                        "_type": "furious.async.Async",
                    },
                },
            }
        )

        self.assertEqual(options, context.to_dict())
开发者ID:thianpengter-wf,项目名称:furious,代码行数:47,代码来源:test_context.py

示例7: test_to_dict

# 需要导入模块: from furious.context import Context [as 别名]
# 或者: from furious.context.Context import to_dict [as 别名]
    def test_to_dict(self):
        """Ensure to_dict returns a dictionary representation of the Context.
        """
        import copy

        from furious.context import Context

        options = {
            'persistence_engine': 'persistence_engine',
            'unkown': True,
        }

        context = Context(**copy.deepcopy(options))

        # This stuff gets dumped out by to_dict().
        options.update({
            'insert_tasks': 'furious.context.context._insert_tasks',
            '_tasks_inserted': False,
            '_task_ids': [],
        })

        self.assertEqual(options, context.to_dict())
开发者ID:dustinhiatt-wf,项目名称:furious,代码行数:24,代码来源:test_context.py


注:本文中的furious.context.Context.to_dict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。