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


Python Dependency.stop_ec2_instance方法代碼示例

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


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

示例1: TestCustomAnalyticsExecutor

# 需要導入模塊: from common.utilities.inversion_of_control import Dependency [as 別名]
# 或者: from common.utilities.inversion_of_control.Dependency import stop_ec2_instance [as 別名]

#.........這裏部分代碼省略.........
        self.mock_config.custom_analytics_retail_login = "chilly"
        self.mock_config.custom_analytics_retail_password = "willy"

        # define expected data
        expected_login_params = { "email": "chilly", "password": "willy" }
        expected_email_url = "/api/custom_analytics/send_success_email/korean_fried_chicken"

        # define some mock objects to return
        mock_login_response = self.mox.CreateMockAnything()
        mock_login_response.cookies = "MortyDog"

        # begin stubbing
        self.mox.StubOutClassWithMocks(web_access, "CoreWebAccess")

        # begin recording
        mock_retail_access = web_access.CoreWebAccess("chicken_woot")
        mock_retail_access.post("/login", expected_login_params).AndReturn(mock_login_response)
        mock_retail_access.get(expected_email_url, cookies="MortyDog")

        # replay all
        self.mox.ReplayAll()

        # I love gooooooold
        CustomAnalyticsExecutor()._send_success_email("korean_fried_chicken")


    def test_shut_down_worker_server(self):

        # begin stubbing
        self.mox.StubOutWithMock(operations, "local")

        # begin recording
        operations.local("wget -q -O - http://169.254.169.254/latest/meta-data/instance-id", True).AndReturn("chicken_woot")
        self.mock_cloud_provider.stop_ec2_instance("chicken_woot")

        # replay all
        self.mox.ReplayAll()

        # go
        CustomAnalyticsExecutor()._shut_down_worker_server()


    def test_handle_error(self):

        # create some mock values
        mock_start_date = datetime.datetime(2014, 3, 11, 0, 0, 0)
        mock_end_date = datetime.datetime(2014, 3, 11, 0, 0, 45)
        mock_subject = "Error running geoprocessing"
        mock_body = '\n'.join([
            "Source: Custom Analytics Executor"
            "Worker Machine: %s" % get_host_name(),
            "Build Start Time (UTC): %s" % str(mock_start_date),
            "Build End Time (UTC): %s" % str(mock_end_date),
            "Elapsed Time: 45.000000",
            "",
            "Client Name: a",
            "Client Email: bear",
            "Report Name: wuzzy",
            "Target Database Name: was",
            "CA Run ID: fuzzy",
            "",
            "Exception: woot",
            "Stack Trace: chicken"
        ])

        # mock some config values
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:70,代碼來源:test_custom_analytics_executor.py


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