• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_helpers.d函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.support.test_helpers.d函数的典型用法代码示例。如果您正苦于以下问题:Python d函数的具体用法?Python d怎么用?Python d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_period_group_query_adds_missing_periods_in_correct_order

    def test_period_group_query_adds_missing_periods_in_correct_order(self):
        self.mock_storage.execute_query.return_value = [
            {'some_group': 'val1', '_week_start_at': d(2013, 1, 14), '_count': 23},
            {'some_group': 'val1', '_week_start_at': d(2013, 1, 21), '_count': 41},
            {'some_group': 'val2', '_week_start_at': d(2013, 1, 14), '_count': 31},
            {'some_group': 'val2', '_week_start_at': d(2013, 1, 28), '_count': 12},
        ]

        data = self.data_set.execute_query(
            Query.create(period=WEEK, group_by=['some_group'],
                         start_at=d_tz(2013, 1, 7, 0, 0, 0),
                         end_at=d_tz(2013, 2, 4, 0, 0, 0)))

        assert_that(data, has_item(has_entries({
            "some_group": "val1",
            "values": contains(
                has_entries({"_start_at": d_tz(2013, 1, 7), "_count": 0}),
                has_entries({"_start_at": d_tz(2013, 1, 14), "_count": 23}),
                has_entries({"_start_at": d_tz(2013, 1, 21), "_count": 41}),
                has_entries({"_start_at": d_tz(2013, 1, 28), "_count": 0}),
            ),
        })))

        assert_that(data, has_item(has_entries({
            "some_group": "val2",
            "values": contains(
                has_entries({"_start_at": d_tz(2013, 1, 7), "_count": 0}),
                has_entries({"_start_at": d_tz(2013, 1, 14), "_count": 31}),
                has_entries({"_start_at": d_tz(2013, 1, 21), "_count": 0}),
                has_entries({"_start_at": d_tz(2013, 1, 28), "_count": 12}),
            ),
        })))
开发者ID:NRCan,项目名称:backdrop,代码行数:32,代码来源:test_data_set.py


示例2: test_query_with_start_at_and__end_at

    def test_query_with_start_at_and__end_at(self):
        query = Query.create(end_at=d(2013, 3, 1, 12, 0, 0),
                             start_at=d(2013, 2, 1, 12, 0, 0))
        self.bucket.query(query)

        self.mock_repository.find.assert_called_with(query, sort=None,
                                                     limit=None)
开发者ID:jcbashdown,项目名称:backdrop,代码行数:7,代码来源:test_bucket.py


示例3: test_sorted_week_and_group_query_with_limit

    def test_sorted_week_and_group_query_with_limit(self):
        self.mock_repository.multi_group.return_value = [
            {
                "some_group": "val1",
                "_count": 6,
                "_group_count": 2,
                "_subgroup": [
                    {
                        "_week_start_at": d(2013, 1, 7, 0, 0, 0),
                        "_count": 1
                    },
                    {
                        "_week_start_at": d(2013, 1, 14, 0, 0, 0),
                        "_count": 5
                    }
                ]
            }
        ]

        query = Query.create(period="week", group_by="some_group",
                             sort_by=["_count", "descending"], limit=1,
                             collect=[])
        self.bucket.query(query)

        self.mock_repository.multi_group.assert_called_with(
            "some_group",
            "_week_start_at",
            query,
            sort=["_count", "descending"],
            limit=1,
            collect=[])
开发者ID:jcbashdown,项目名称:backdrop,代码行数:31,代码来源:test_bucket.py


示例4: test_period_group_query_fails_when_weeks_do_not_start_on_monday

    def test_period_group_query_fails_when_weeks_do_not_start_on_monday(self):
        multi_group_results = [
            {
                "is": "Monday",
                "_subgroup": [
                    {"_week_start_at": d(2013, 4, 1), "_count": 1}
                ]
            },
            {
                "is": "also Monday",
                "_subgroup": [
                    {"_week_start_at": d(2013, 4, 8), "_count": 1}
                ]
            },
            {
                "is": "Tuesday",
                "_subgroup": [
                    {"_week_start_at": d(2013, 4, 9), "_count": 1}
                ]
            },
        ]

        self.mock_repository.multi_group.return_value = \
            multi_group_results

        query = Query.create(period=WEEK, group_by='d')
        assert_raises(ValueError, self.bucket.query, query)
开发者ID:pwaller,项目名称:backdrop,代码行数:27,代码来源:test_bucket.py


示例5: test_period_group_query_fails_when_weeks_do_not_start_on_monday

    def test_period_group_query_fails_when_weeks_do_not_start_on_monday(self):
        multi_group_results = [
            {
                "is": "Monday",
                "_subgroup": [
                    {"_week_start_at": d(2013, 4, 1), "_count": 1}
                ]
            },
            {
                "is": "also Monday",
                "_subgroup": [
                    {"_week_start_at": d(2013, 4, 8), "_count": 1}
                ]
            },
            {
                "is": "Tuesday",
                "_subgroup": [
                    {"_week_start_at": d(2013, 4, 9), "_count": 1}
                ]
            },
        ]

        self.mock_repository.multi_group.return_value = \
            multi_group_results

        try:
            self.bucket.query(Query.create(period='week', group_by='d')).data()
            assert_that(False)
        except ValueError as e:
            assert_that(str(e), is_(
                "Weeks MUST start on Monday but got date: 2013-04-09 00:00:00"
            ))
开发者ID:jcbashdown,项目名称:backdrop,代码行数:32,代码来源:test_bucket.py


示例6: test_period_group_query_adds_missing_periods_in_correct_order

    def test_period_group_query_adds_missing_periods_in_correct_order(self):
        self.mock_repository.multi_group.return_value = [
            {
                "some_group": "val1",
                "_count": 6,
                "_group_count": 2,
                "_subgroup": [
                    {
                        "_week_start_at": d(2013, 1, 14, 0, 0, 0),
                        "_count": 23
                    },
                    {
                        "_week_start_at": d(2013, 1, 21, 0, 0, 0),
                        "_count": 41
                    }
                ]
            },
            {
                "some_group": "val2",
                "_count": 8,
                "_group_count": 2,
                "_subgroup": [
                    {
                        "_week_start_at": d(2013, 1, 14, 0, 0, 0),
                        "_count": 31
                    },
                    {
                        "_week_start_at": d(2013, 1, 28, 0, 0, 0),
                        "_count": 12
                    }
                ]
            }
        ]

        query_result = self.bucket.query(
            Query.create(period="week", group_by="some_group",
                         start_at=d_tz(2013, 1, 7, 0, 0, 0),
                         end_at=d_tz(2013, 2, 4, 0, 0, 0))).data()

        assert_that(query_result, has_item(has_entries({
            "some_group": "val1",
            "values": contains(
                has_entries({"_start_at": d_tz(2013, 1, 7), "_count": 0}),
                has_entries({"_start_at": d_tz(2013, 1, 14), "_count": 23}),
                has_entries({"_start_at": d_tz(2013, 1, 21), "_count": 41}),
                has_entries({"_start_at": d_tz(2013, 1, 28), "_count": 0}),
            ),
        })))

        assert_that(query_result, has_item(has_entries({
            "some_group": "val2",
            "values": contains(
                has_entries({"_start_at": d_tz(2013, 1, 7), "_count": 0}),
                has_entries({"_start_at": d_tz(2013, 1, 14), "_count": 31}),
                has_entries({"_start_at": d_tz(2013, 1, 21), "_count": 0}),
                has_entries({"_start_at": d_tz(2013, 1, 28), "_count": 12}),
            ),
        })))
开发者ID:jcbashdown,项目名称:backdrop,代码行数:58,代码来源:test_bucket.py


示例7: test_that_it_returns_the_end_of_the_current_month

    def test_that_it_returns_the_end_of_the_current_month(self):
        some_datetime = d(2013, 10, 4, 10, 23, 43)
        some_other_datetime = d(2013, 10, 4)

        end = MONTH.end(some_datetime)
        other_end = MONTH.end(some_other_datetime)

        assert_that(end, is_(d(2013, 11, 1)))
        assert_that(other_end, is_(d(2013, 11, 1)))
开发者ID:frabcus,项目名称:backdrop,代码行数:9,代码来源:test_timeseries.py


示例8: test_adding_multiple_mongo_documents

 def test_adding_multiple_mongo_documents(self):
     stub_document_1 = {
         "_subgroup": [ {"_week_start_at": d(2013, 4, 1), "_count": 5} ]
     }
     stub_document_2 = {
         "_subgroup": [ {"_week_start_at": d(2013, 4, 1), "_count": 5} ]
     }
     data = PeriodGroupedData([stub_document_1, stub_document_2], WEEK)
     assert_that(data.data(), has_length(2))
开发者ID:frabcus,项目名称:backdrop,代码行数:9,代码来源:test_weekly_grouped_data.py


示例9: test_that_middle_of_quarters_are_invalid

    def test_that_middle_of_quarters_are_invalid(self):
        middle_first_quarter = d(2013, 1, 10, 0, 0, 0)
        middle_second_quarter = d(2013, 4, 15, 0, 0, 0)
        middle_third_quarter = d(2013, 7, 20, 0, 0, 0)
        middle_fourth_quarter = d(2013, 10, 13, 0, 0, 0)

        assert_that(QUARTER.valid_start_at(middle_first_quarter), is_(False))
        assert_that(QUARTER.valid_start_at(middle_second_quarter), is_(False))
        assert_that(QUARTER.valid_start_at(middle_third_quarter), is_(False))
        assert_that(QUARTER.valid_start_at(middle_fourth_quarter), is_(False))
开发者ID:NRCan,项目名称:backdrop,代码行数:10,代码来源:test_timeseries.py


示例10: test_that_beginning_of_quarters_are_valid

    def test_that_beginning_of_quarters_are_valid(self):
        first_quarter = d(2013, 1, 1, 0, 0, 0)
        second_quarter = d(2013, 4, 1, 0, 0, 0)
        third_quarter = d(2013, 7, 1, 0, 0, 0)
        fourth_quarter = d(2013, 10, 1, 0, 0, 0)

        assert_that(QUARTER.valid_start_at(first_quarter), is_(True))
        assert_that(QUARTER.valid_start_at(second_quarter), is_(True))
        assert_that(QUARTER.valid_start_at(third_quarter), is_(True))
        assert_that(QUARTER.valid_start_at(fourth_quarter), is_(True))
开发者ID:pwaller,项目名称:backdrop,代码行数:10,代码来源:test_timeseries.py


示例11: test_period_query_fails_when_months_do_not_start_on_the_1st

    def test_period_query_fails_when_months_do_not_start_on_the_1st(self):
        self.mock_storage.execute_query.return_value = [
            {"_month_start_at": d(2013, 1, 7, 0, 0, 0), "_count": 3},
            {"_month_start_at": d(2013, 2, 8, 0, 0, 0), "_count": 1},
        ]

        assert_raises(
            ValueError,
            self.data_set.execute_query,
            Query.create(period=MONTH)
        )
开发者ID:NRCan,项目名称:backdrop,代码行数:11,代码来源:test_data_set.py


示例12: test_period_query_fails_when_months_do_not_start_on_the_1st

    def test_period_query_fails_when_months_do_not_start_on_the_1st(self):
        self.mock_repository.group.return_value = [
            {"_month_start_at": d(2013, 1, 7, 0, 0, 0), "_count": 3},
            {"_month_start_at": d(2013, 2, 8, 0, 0, 0), "_count": 1},
        ]

        self.assertRaises(
            ValueError,
            self.bucket.query,
            Query.create(period='month')
        )
开发者ID:jcbashdown,项目名称:backdrop,代码行数:11,代码来源:test_bucket.py


示例13: test_month_query

    def test_month_query(self):
        self.mock_repository.group.return_value = [
            {"_month_start_at": d(2013, 4, 1), "_count": 1},
            {"_month_start_at": d(2013, 5, 1), "_count": 3}
        ]

        query = Query.create(period="month")
        query_result = self.bucket.query(query).data()
        self.mock_repository.group.assert_called_once_with(
            "_month_start_at", query, sort=['_month_start_at', 'ascending'],
            limit=None, collect=[])
开发者ID:jcbashdown,项目名称:backdrop,代码行数:11,代码来源:test_bucket.py


示例14: test_period_query_fails_when_weeks_do_not_start_on_monday

    def test_period_query_fails_when_weeks_do_not_start_on_monday(self):
        self.mock_storage.execute_query.return_value = [
            {"_week_start_at": d(2013, 1, 7, 0, 0, 0), "_count": 3},
            {"_week_start_at": d(2013, 1, 8, 0, 0, 0), "_count": 1},
        ]

        assert_raises(
            ValueError,
            self.data_set.execute_query,
            Query.create(period=WEEK)
        )
开发者ID:NRCan,项目名称:backdrop,代码行数:11,代码来源:test_data_set.py


示例15: test_key1_is_pulled_to_the_top_of_outer_group

    def test_key1_is_pulled_to_the_top_of_outer_group(self):
        self.setUpPeopleLocationData()

        results = self.repo.multi_group("_week_start_at", "person", Query.create())

        assert_that(results, has_item(has_entry(
            "_week_start_at", d(2013, 3, 11)
        )))
        assert_that(results, has_item(has_entry(
            "_week_start_at", d(2013, 3, 25)
        )))
开发者ID:pwaller,项目名称:backdrop,代码行数:11,代码来源:test_database_integration.py


示例16: test_end_of_quarter_is_beginning_of_next_quarter

    def test_end_of_quarter_is_beginning_of_next_quarter(self):
        first_quarter = d(2013, 1, 1, 0, 0, 0)
        second_quarter = d(2013, 4, 1, 0, 0, 0)
        third_quarter = d(2013, 7, 1, 0, 0, 0)
        fourth_quarter = d(2013, 10, 1, 0, 0, 0)
        first_quarter_2014 = d(2014, 1, 1, 0, 0, 0)

        assert_that(QUARTER.end(first_quarter.replace(hour=1)), is_(second_quarter))
        assert_that(QUARTER.end(second_quarter.replace(hour=1)), is_(third_quarter))
        assert_that(QUARTER.end(third_quarter.replace(hour=1)), is_(fourth_quarter))
        assert_that(QUARTER.end(fourth_quarter.replace(hour=1)), is_(first_quarter_2014))
开发者ID:NRCan,项目名称:backdrop,代码行数:11,代码来源:test_timeseries.py


示例17: test_period_datum_week_start_at_should_be_monday

    def test_period_datum_week_start_at_should_be_monday(self):
        stub_doc = {
            "_week_start_at": d(2013, 5, 4),
            "_count": 0
        }

        try:
            period_data = PeriodData([stub_doc], period="week")
            assert_that(False, "expected exception")
        except ValueError as e:
            assert_that(str(e), is_("Weeks MUST start on Monday but got date:"
                                    " " + str(d(2013, 5, 4))))
开发者ID:jcbashdown,项目名称:backdrop,代码行数:12,代码来源:test_period_data.py


示例18: test_multi_group_is_sorted_by_inner_key

    def test_multi_group_is_sorted_by_inner_key(self):
        self.setUpPeopleLocationData()

        results = self.repo.multi_group("person", "_week_start_at", Query.create())

        assert_that(results, has_item(has_entries({
            "person": "John",
            "_subgroup": contains(
                has_entry("_week_start_at", d(2013, 3, 11)),
                has_entry("_week_start_at", d(2013, 3, 18)),
            )
        })))
开发者ID:pwaller,项目名称:backdrop,代码行数:12,代码来源:test_database_integration.py


示例19: test_filling_data_for_missing_month_periods

    def test_filling_data_for_missing_month_periods(self):
        stub_doc_1 = {
            "_month_start_at": d(2013, 4, 1),
            "_count": 5

        }
        stub_doc_2 = {
            "_month_start_at": d(2013, 6, 1),
            "_count": 6
        }
        period_data = PeriodData([stub_doc_1, stub_doc_2], period="month")
        period_data.fill_missing_periods(d(2013, 4, 1), d(2013, 6, 2))
        assert_that(period_data.data(), has_length(3))
开发者ID:jcbashdown,项目名称:backdrop,代码行数:13,代码来源:test_period_data.py


示例20: test_sorted_week_and_group_query_with_limit

    def test_sorted_week_and_group_query_with_limit(self):
        self.mock_storage.execute_query.return_value = [
            {'some_group': 'val1', '_week_start_at': d(2013, 1, 7), '_count': 1},
            {'some_group': 'val2', '_week_start_at': d(2013, 1, 14), '_count': 5},
        ]

        query = Query.create(period=WEEK, group_by=['some_group'],
                             sort_by=["_count", "descending"], limit=1,
                             collect=[])
        data = self.data_set.execute_query(query)

        assert_that(data, contains(
            has_entries({'some_group': 'val2'})
        ))
开发者ID:NRCan,项目名称:backdrop,代码行数:14,代码来源:test_data_set.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_helpers.d_tz函数代码示例发布时间:2022-05-27
下一篇:
Python mock.patch函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap