當前位置: 首頁>>代碼示例>>Python>>正文


Python Dependency.execute_controller方法代碼示例

本文整理匯總了Python中common.utilities.inversion_of_control.Dependency.execute_controller方法的典型用法代碼示例。如果您正苦於以下問題:Python Dependency.execute_controller方法的具體用法?Python Dependency.execute_controller怎麽用?Python Dependency.execute_controller使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common.utilities.inversion_of_control.Dependency的用法示例。


在下文中一共展示了Dependency.execute_controller方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestCustomAnalyticsExecutor

# 需要導入模塊: from common.utilities.inversion_of_control import Dependency [as 別名]
# 或者: from common.utilities.inversion_of_control.Dependency import execute_controller [as 別名]
class TestCustomAnalyticsExecutor(mox.MoxTestBase):

    def setUp(self):

        # call parent set up
        super(TestCustomAnalyticsExecutor, self).setUp()

        # register mock dependencies
        register_common_mox_dependencies(self.mox)

        # get some mock dependencies
        self.mock_deployment_provider = Dependency("DeploymentProvider").value
        self.mock_cloud_provider = Dependency("CloudProviderNewEnvironment").value
        self.mock_logger = Dependency("LogManager").value
        self.mock_email_provider = Dependency("EmailProvider").value
        self.mock_config = Dependency("Config").value


    def doCleanups(self):

        # call parent clean up
        super(TestCustomAnalyticsExecutor, self).doCleanups()

        # clear dependencies
        dependencies.clear()


    def test_complete_run__success(self):

        # create executor
        executor = CustomAnalyticsExecutor()

        # stub out some stuff
        self.mox.StubOutWithMock(executor, "_update_path")
        self.mox.StubOutWithMock(executor, "_update_and_reset_config")
        self.mox.StubOutWithMock(executor, "_update_ca_run_status")
        self.mox.StubOutWithMock(executor, "_clear_log_file")
        self.mox.StubOutWithMock(executor, "_execute_controller")
        self.mox.StubOutWithMock(executor, "_run_data_checks")
        self.mox.StubOutWithMock(executor, "_run_custom_analytics")
        self.mox.StubOutWithMock(executor, "_upload_file_to_rds")
        self.mox.StubOutWithMock(executor, "_shrink_db")
        self.mox.StubOutWithMock(executor, "_send_success_email")
        self.mox.StubOutWithMock(executor, "_shut_down_worker_server")

        # begin recording
        executor._update_path()
        executor._update_and_reset_config().AndReturn(("fuzzy", "wuzzy-stripped", "was", "a", "bear", "chicken", "woot", "borat", "sagdiev"))
        executor._update_ca_run_status()
        executor._clear_log_file()
        executor._execute_controller()
        executor._run_data_checks("fuzzy", "wuzzy-stripped", "was", "a", "bear").AndReturn(True)
        executor._run_custom_analytics("chicken", "woot", "wuzzy stripped", "borat", "sagdiev")
        executor._upload_file_to_rds("fuzzy", "wuzzy stripped").AndReturn("PATH")
        executor._shrink_db("was")
        executor._update_ca_run_status("success", "success", "PATH", True)
        executor._send_success_email("fuzzy")
        executor._shut_down_worker_server()

        # replay all
        self.mox.ReplayAll()

        # I love gooooooold
        executor.execute()

        # make sure the ca id set for the heart beat
        self.assertEqual(executor._custom_analytics_run_id, "fuzzy")


    def test_complete_run__success__data_checks_fail(self):

        # create executor
        executor = CustomAnalyticsExecutor()

        # stub out some stuff
        self.mox.StubOutWithMock(executor, "_update_path")
        self.mox.StubOutWithMock(executor, "_update_and_reset_config")
        self.mox.StubOutWithMock(executor, "_update_ca_run_status")
        self.mox.StubOutWithMock(executor, "_clear_log_file")
        self.mox.StubOutWithMock(executor, "_execute_controller")
        self.mox.StubOutWithMock(executor, "_run_data_checks")
        self.mox.StubOutWithMock(executor, "_run_custom_analytics")
        self.mox.StubOutWithMock(executor, "_upload_file_to_rds")
        self.mox.StubOutWithMock(executor, "_shrink_db")
        self.mox.StubOutWithMock(executor, "_send_success_email")
        self.mox.StubOutWithMock(executor, "_shut_down_worker_server")

        # begin recording
        executor._update_path()
        executor._update_and_reset_config().AndReturn(("fuzzy", "wuzzy", "was", "a", "bear", "chicken", "woot", "borat", "sagdiev"))
        executor._update_ca_run_status()
        executor._clear_log_file()
        executor._execute_controller()
        executor._run_data_checks("fuzzy", "wuzzy", "was", "a", "bear").AndReturn(False)
        executor._update_ca_run_status("data_checks_failed")
        executor._shut_down_worker_server()

        # replay all
        self.mox.ReplayAll()

#.........這裏部分代碼省略.........
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:103,代碼來源:test_custom_analytics_executor.py


注:本文中的common.utilities.inversion_of_control.Dependency.execute_controller方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。