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


Python OpenEdXInstanceFactory.refresh_from_db方法代码示例

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


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

示例1: test_set_appserver_active

# 需要导入模块: from instance.tests.models.factories.openedx_instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.openedx_instance.OpenEdXInstanceFactory import refresh_from_db [as 别名]
 def test_set_appserver_active(self, mocks):
     """
     Test set_appserver_active()
     """
     instance = OpenEdXInstanceFactory(internal_lms_domain='test.activate.opencraft.co.uk',
                                       use_ephemeral_databases=True)
     appserver_id = instance.spawn_appserver()
     instance.set_appserver_active(appserver_id)
     instance.refresh_from_db()
     self.assertEqual(instance.active_appserver.pk, appserver_id)
     self.assertEqual(mocks.mock_load_balancer_run_playbook.call_count, 2)
     instance.set_appserver_inactive()
     instance.refresh_from_db()
     self.assertIsNone(instance.active_appserver)
     self.assertEqual(mocks.mock_load_balancer_run_playbook.call_count, 3)
开发者ID:open-craft,项目名称:opencraft,代码行数:17,代码来源:test_openedx_instance.py

示例2: test_make_active

# 需要导入模块: from instance.tests.models.factories.openedx_instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.openedx_instance.OpenEdXInstanceFactory import refresh_from_db [as 别名]
    def test_make_active(self, mock_run_playbook):
        """
        POST /api/v1/openedx_appserver/:id/make_active/ - Make this OpenEdXAppServer active
        for its given instance.

        This can be done at any time; the AppServer must be healthy but "New",
        "WaitingForServer", etc. are all considered healthy states, so the AppServer does not
        necessarily have to be fully provisioned and online.
        """
        self.api_client.login(username='user3', password='pass')
        instance = OpenEdXInstanceFactory(edx_platform_commit='1' * 40, use_ephemeral_databases=True)
        app_server = make_test_appserver(instance)
        self.assertEqual(instance.active_appserver, None)

        response = self.api_client.post('/api/v1/openedx_appserver/{pk}/make_active/'.format(pk=app_server.pk))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, {'status': 'App server activation initiated.'})
        self.assertEqual(mock_run_playbook.call_count, 1)

        instance.refresh_from_db()
        self.assertEqual(instance.active_appserver, app_server)
开发者ID:open-craft,项目名称:opencraft,代码行数:23,代码来源:test_openedx_appserver.py

示例3: test_spawn_appserver

# 需要导入模块: from instance.tests.models.factories.openedx_instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.openedx_instance.OpenEdXInstanceFactory import refresh_from_db [as 别名]
    def test_spawn_appserver(self, mock_run_playbook, mock_provision):
        """
        POST /api/v1/openedx_appserver/ - Spawn a new OpenEdXAppServer for the given instance.

        This can be done at any time; there are no restrictions on when a new AppServer can be
        spawned.
        """
        self.api_client.login(username='user3', password='pass')
        instance = OpenEdXInstanceFactory(edx_platform_commit='1' * 40, use_ephemeral_databases=True)
        self.assertEqual(instance.appserver_set.count(), 0)
        self.assertEqual(instance.active_appserver, None)

        response = self.api_client.post('/api/v1/openedx_appserver/', {'instance_id': instance.ref.pk})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, {'status': 'Instance provisioning started'})
        self.assertEqual(mock_provision.call_count, 1)
        instance.refresh_from_db()

        self.assertEqual(instance.appserver_set.count(), 1)
        # Even though provisioning succeeded, the API does not make app servers active automatically:
        self.assertEqual(instance.active_appserver, None)

        app_server = instance.appserver_set.first()
        self.assertEqual(app_server.edx_platform_commit, '1' * 40)
开发者ID:open-craft,项目名称:opencraft,代码行数:26,代码来源:test_openedx_appserver.py


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