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


Python Dependency.update_config_with_custom_analytics_settings方法代码示例

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


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

示例1: TestCustomAnalyticsExecutor

# 需要导入模块: from common.utilities.inversion_of_control import Dependency [as 别名]
# 或者: from common.utilities.inversion_of_control.Dependency import update_config_with_custom_analytics_settings [as 别名]

#.........这里部分代码省略.........
            "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
        self.mock_config.email_settings_from_email = "chicken"
        self.mock_config.report_generator_email_recipients_developers = "woot"

        # stub out date time, which is used when creating the executor
        self.mox.StubOutWithMock(datetime, "datetime")

        # record the first datetime
        datetime.datetime.utcnow().AndReturn(mock_start_date)

        # replay all (early) to make sure the executor gets the right start date
        self.mox.ReplayAll()

        # create the executor
        executor = CustomAnalyticsExecutor()

        # reset the recordings so that we can rerecord the actual method execution
        self.mox.ResetAll()

        # begin stubbing
        self.mox.StubOutWithMock(executor, "_update_ca_run_status")

        # begin recording
        executor._update_ca_run_status("error", error_string = "woot", error_stack_trace = "chicken")
        datetime.datetime.utcnow().AndReturn(mock_end_date)
        self.mock_email_provider.send_email("chicken", "woot", mock_subject, mock_body)

        # replay all
        self.mox.ReplayAll()

        # I love gooooooold
        executor._handle_error("woot", "chicken", "fuzzy", "wuzzy", "was", "a", "bear")


    def test_update_and_reset_config__set_values(self):

        # create mock configuration
        mock_configuration = json.dumps({
            "ca_run_id": "chicken",
            "demographic_template": "woot",
            "trade_areas": "chilly",
            "target_db": "willy",
            "target_db_logging": "mdog",
            "report_name": "arnie",
            "client_name": "arnold",
            "client_email": "[email protected]",
            "company_settings": "Morty",
            "time_periods": "Dog",
            "run_comp_stores_report": "borat",
            "comp_stores_periods": "sagdiev"
        })

        # begin recording
        self.mock_config.update_config_with_custom_analytics_settings("chicken", "woot", "chilly", "willy", "mdog", "arnie", "arnold", "[email protected]",
                                                                      "Morty", "Dog", "borat", "sagdiev").AndReturn("yo mama")

        # replay all
        self.mox.ReplayAll()

        # I love gooooooold
        executor = CustomAnalyticsExecutor(mock_configuration)
        results = executor._update_and_reset_config()

        # make sure results are good
        self.assertEqual(results, ("chicken", "arnie", "willy", "arnold", "[email protected]", "Morty", "Dog", "borat", "sagdiev"))
        self.assertEqual(executor._config, "yo mama")


    def test_update_and_reset_config__do_not_set_values(self):

        # set some settings in the mock_config
        self.mock_config.custom_analytics_run_id = "chicken"
        self.mock_config.custom_analytics_report_name = "arnie"
        self.mock_config.db_database = "willy"
        self.mock_config.custom_analytics_client_name = "arnold"
        self.mock_config.custom_analytics_client_email = "[email protected]"
        self.mock_config.custom_analytics_company_settings = "Morty"
        self.mock_config.custom_analytics_time_periods = "Dog"
        self.mock_config.custom_analytics_run_comp_stores_report = "borat"
        self.mock_config.custom_analytics_comp_stores_periods = "sagdiev"

        # I love gooooooold
        results = CustomAnalyticsExecutor()._update_and_reset_config()

        # make sure results are good
        self.assertEqual(results, ("chicken", "arnie", "willy", "arnold", "[email protected]", "Morty", "Dog", "borat", "sagdiev"))
开发者ID:erezrubinstein,项目名称:aa,代码行数:104,代码来源:test_custom_analytics_executor.py


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