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

Python test_helpers.d_tz函数代码示例

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

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



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

示例1: test_month_and_group_query_with_start_and_end_at

    def test_month_and_group_query_with_start_and_end_at(self):
        self.mock_storage.execute_query.return_value = [
            {'some_group': 'val1', '_month_start_at': d(2013, 1, 1), '_count': 1},
            {'some_group': 'val1', '_month_start_at': d(2013, 2, 1), '_count': 5},
            {'some_group': 'val2', '_month_start_at': d(2013, 3, 1), '_count': 2},
            {'some_group': 'val2', '_month_start_at': d(2013, 4, 1), '_count': 6},
            {'some_group': 'val2', '_month_start_at': d(2013, 7, 1), '_count': 6},
        ]

        data = self.data_set.execute_query(
            Query.create(period=MONTH,
                         group_by=['some_group'],
                         start_at=d(2013, 1, 1),
                         end_at=d(2013, 4, 2)))
        assert_that(data,
                    has_item(has_entries({"values": has_length(4)})))
        assert_that(data,
                    has_item(has_entries({"values": has_length(4)})))

        first_group = data[0]["values"]
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 3, 1)})))
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 4, 1)})))

        first_group = data[1]["values"]
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 1, 1)})))
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 2, 1)})))
开发者ID:NRCan,项目名称:backdrop,代码行数:30,代码来源:test_data_set.py


示例2: test_basic_query_with_time_limits

    def test_basic_query_with_time_limits(self):
        self._save_all('foo_bar',
                       {'_timestamp': d_tz(2012, 12, 12)},
                       {'_timestamp': d_tz(2012, 12, 14)},
                       {'_timestamp': d_tz(2012, 12, 11)})

        # start at
        results = self.engine.execute_query('foo_bar', Query.create(
            start_at=d_tz(2012, 12, 12, 13)))

        assert_that(results,
                    contains(
                        has_entry('_timestamp', d_tz(2012, 12, 14))))

        # end at
        results = self.engine.execute_query('foo_bar', Query.create(
            end_at=d_tz(2012, 12, 11, 13)))

        assert_that(results,
                    contains(
                        has_entry('_timestamp', d_tz(2012, 12, 11))))

        # both
        results = self.engine.execute_query('foo_bar', Query.create(
            start_at=d_tz(2012, 12, 11, 12),
            end_at=d_tz(2012, 12, 12, 12)))

        assert_that(results,
                    contains(
                        has_entry('_timestamp', d_tz(2012, 12, 12))))
开发者ID:alphagov,项目名称:backdrop,代码行数:30,代码来源:test_storage.py


示例3: 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


示例4: test_month_and_group_query_with_start_and_end_at

    def test_month_and_group_query_with_start_and_end_at(self):
        self.mock_repository.multi_group.return_value = [
            {
                "some_group": "val1",
                "_count": 6,
                "_group_count": 2,
                "_subgroup": [
                    {
                        "_month_start_at": d(2013, 1, 1, 0, 0, 0),
                        "_count": 1
                    },
                    {
                        "_month_start_at": d(2013, 2, 1, 0, 0, 0),
                        "_count": 5
                    }
                ]
            },
            {
                "some_group": "val2",
                "_count": 8,
                "_group_count": 2,
                "_subgroup": [
                    {
                        "_month_start_at": d(2013, 3, 1, 0, 0, 0),
                        "_count": 2
                    },
                    {
                        "_month_start_at": d(2013, 4, 1, 0, 0, 0),
                        "_count": 6
                    },
                    {
                        "_month_start_at": d(2013, 7, 1, 0, 0, 0),
                        "_count": 6
                    }
                ]
            }
        ]

        query_result = self.bucket.query(Query.create(period=MONTH,
                                                      group_by="some_group",
                                                      start_at=d(2013, 1, 1),
                                                      end_at=d(2013, 4, 2)))
        data = query_result.data()
        assert_that(data,
                    has_item(has_entries({"values": has_length(4)})))
        assert_that(data,
                    has_item(has_entries({"values": has_length(4)})))

        first_group = data[0]["values"]
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 3, 1)})))
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 4, 1)})))

        first_group = data[1]["values"]
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 1, 1)})))
        assert_that(first_group, has_item(has_entries({
            "_start_at": d_tz(2013, 2, 1)})))
开发者ID:pwaller,项目名称:backdrop,代码行数:59,代码来源:test_bucket.py


示例5: 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


示例6: test_period_queries_get_sorted_by__week_start_at

 def test_period_queries_get_sorted_by__week_start_at(self):
     self.setup__timestamp_data()
     query = Query.create(period="week")
     result = query.execute(self.bucket.repository)
     assert_that(result.data(), contains(
         has_entry('_start_at', d_tz(2012, 12, 31)),
         has_entry('_start_at', d_tz(2013, 1, 28)),
         has_entry('_start_at', d_tz(2013, 2, 25))
     ))
开发者ID:jcbashdown,项目名称:backdrop,代码行数:9,代码来源:test_bucket_integration.py


示例7: test_save_document_adding_timestamps

    def test_save_document_adding_timestamps(self, now):
        now.return_value = d_tz(2013, 4, 9, 13, 32, 5)

        self.repo.save({"name": "Gummo"})

        self.mongo.save.assert_called_once_with({
            "name": "Gummo",
            "_updated_at": d_tz(2013, 4, 9, 13, 32, 5)
        })
开发者ID:jcbashdown,项目名称:backdrop,代码行数:9,代码来源:test_database.py


示例8: test_period_queries_get_sorted_by__week_start_at

 def test_period_queries_get_sorted_by__week_start_at(self):
     self.setup__timestamp_data()
     query = Query.create(period=WEEK)
     result = self.data_set.execute_query(query)
     assert_that(result, contains(
         has_entry('_start_at', d_tz(2012, 12, 31)),
         has_entry('_start_at', d_tz(2013, 1, 28)),
         has_entry('_start_at', d_tz(2013, 2, 25))
     ))
开发者ID:NRCan,项目名称:backdrop,代码行数:9,代码来源:test_data_set_integration.py


示例9: test_build_query_with_start_and_end_at

 def test_build_query_with_start_and_end_at(self):
     query = Query.create(
         start_at = d_tz(2012, 3, 17, 17, 10, 6),
         end_at = d_tz(2012, 3, 19, 17, 10, 6))
     assert_that(query.to_mongo_query(), is_({
         "_timestamp": {
             "$gte": d_tz(2012, 3, 17, 17, 10, 6),
             "$lt": d_tz(2012, 3, 19, 17, 10, 6)
         }
     }))
开发者ID:frabcus,项目名称:backdrop,代码行数:10,代码来源:test_query.py


示例10: test_period_query_is_executed

    def test_period_query_is_executed(self, mock_query):
        mock_query.return_value = NoneData()

        self.app.get(
            '/data/some-group/some-type?period=week&' +
            'start_at=' + urllib.quote("2012-11-05T00:00:00Z") + '&' +
            'end_at=' + urllib.quote("2012-12-03T00:00:00Z"))
        mock_query.assert_called_with(
            Query.create(period=WEEK,
                         start_at=d_tz(2012, 11, 5),
                         end_at=d_tz(2012, 12, 3)))
开发者ID:NRCan,项目名称:backdrop,代码行数:11,代码来源:test_read_api_service_data_endpoint.py


示例11: test_basic_query_with_inclusive_time_limits

    def test_basic_query_with_inclusive_time_limits(self):
        self._save_all('foo_bar',
                       {'_timestamp': d_tz(2014, 12, 01)},
                       {'_timestamp': d_tz(2014, 12, 02)},
                       {'_timestamp': d_tz(2014, 12, 03)})

        # start at
        results = self.engine.execute_query('foo_bar', Query.create(
            start_at=d_tz(2014, 12, 01),
            end_at=d_tz(2014, 12, 03),
            inclusive=True))

        assert_that(len(results), is_(3))
开发者ID:alphagov,项目名称:backdrop,代码行数:13,代码来源:test_storage.py


示例12: test_adding_mongo_document_to_collection_expands_week_start_at

    def test_adding_mongo_document_to_collection_expands_week_start_at(self):
        stub_doc = {
            "_week_start_at": d(2013, 5, 6),
            "_count": 42
        }

        period_data = PeriodData([stub_doc], period="week")

        assert_that(len(period_data.data()), is_(1))
        assert_that(period_data.data()[0], has_entry("_count", 42))
        assert_that(period_data.data()[0], has_entry("_start_at",
                                                     d_tz(2013, 5, 6)))
        assert_that(period_data.data()[0], has_entry("_end_at",
                                                     d_tz(2013, 5, 13)))
开发者ID:jcbashdown,项目名称:backdrop,代码行数:14,代码来源:test_period_data.py


示例13: test_week_start_at_gets_expanded_in_subgroups_when_added

 def test_week_start_at_gets_expanded_in_subgroups_when_added(self):
     stub_document = {
         "_subgroup": [
             {
                 "_week_start_at": d(2013, 4, 1),
                 "_count": 5
             }
         ]
     }
     data = PeriodGroupedData([stub_document], WEEK)
     values = data.data()[0]['values']
     assert_that(values, has_item(has_entry("_start_at", d_tz(2013, 4, 1))))
     assert_that(values, has_item(has_entry("_end_at", d_tz(2013, 4, 8))))
     assert_that(values, has_item(has_entry("_count", 5)))
开发者ID:frabcus,项目名称:backdrop,代码行数:14,代码来源:test_weekly_grouped_data.py


示例14: test_adding_mongo_doc_to_collection_expands_month_start_at

    def test_adding_mongo_doc_to_collection_expands_month_start_at(self):
        stub_doc = {
            "_month_start_at": d(2013, 4, 1),
            "_count": 5
        }

        period_data = PeriodData([stub_doc], period="month")

        assert_that(len(period_data.data()), is_(1))
        assert_that(period_data.data()[0], has_entry("_count", 5))
        assert_that(period_data.data()[0], has_entry("_start_at",
                                                     d_tz(2013, 4, 1)))
        assert_that(period_data.data()[0], has_entry("_end_at",
                                                     d_tz(2013, 5, 1)))
开发者ID:jcbashdown,项目名称:backdrop,代码行数:14,代码来源:test_period_data.py


示例15: test_batch_last_updated

    def test_batch_last_updated(self):
        records = {
            # timestamps in ascending order
            'some_data': [
                {'_timestamp': d_tz(2018, 1, 1)},
                {'_timestamp': d_tz(2019, 1, 1)},
                {'_timestamp': d_tz(2020, 1, 1)},
            ],
            # timestamps in descending order
            'some_other_data': [
                {'_timestamp': d_tz(2017, 1, 1)},
                {'_timestamp': d_tz(2016, 1, 1)},
                {'_timestamp': d_tz(2015, 1, 1)},
            ]
        }

        for key, items in records.iteritems():
            self.engine.create_data_set(key, 0)
            for item in items:
                self.engine.save_record(key, item)

        some_data_set = DataSet(self.engine, {'name': 'some_data'})
        some_other_data_set = DataSet(self.engine, {'name': 'some_other_data'})
        yet_another_data_set = DataSet(self.engine, {'name': 'yet_another_data'})

        self.engine.batch_last_updated([some_data_set, some_other_data_set, yet_another_data_set])

        some_data_set_last_updated = some_data_set.get_last_updated()
        some_other_data_set_last_updated = some_other_data_set.get_last_updated()
        yet_another_data_set_last_updated = yet_another_data_set.get_last_updated()

        assert_that(some_data_set_last_updated, is_(d_tz(2020, 1, 1, 0, 0, 0)))
        assert_that(some_other_data_set_last_updated, is_(d_tz(2017, 1, 1, 0, 0, 0)))
        assert_that(yet_another_data_set_last_updated, is_(none()))
开发者ID:alphagov,项目名称:backdrop,代码行数:34,代码来源:test_storage.py


示例16: test_shift_query_backwards

    def test_shift_query_backwards(self):
        query = Query.create(
            start_at=d_tz(2014, 1, 9, 0, 0, 0),
            period=Day(),
            duration=6,
        )

        shifted = query.get_shifted_query(-5)

        assert_that(shifted.start_at, is_(
            d_tz(2014, 1, 4, 0, 0, 0)))

        assert_that(shifted.end_at, is_(
            d_tz(2014, 1, 10, 0, 0, 0)))
开发者ID:NRCan,项目名称:backdrop,代码行数:14,代码来源:test_query.py


示例17: test__timestamp_is_returned_as_datetime

    def test__timestamp_is_returned_as_datetime(self):
        incoming_data = {
            'foo': 'bar',
            '_timestamp': d_tz(
                2013, 2, 2, 0, 2, 0
            )
        }
        some_record = Record(incoming_data)

        assert_that(
            some_record.data['_timestamp'],
            is_(
                d_tz(2013, 2, 2, 0, 2, 0)
            )
        )
开发者ID:frabcus,项目名称:backdrop,代码行数:15,代码来源:test_records.py


示例18: test_that_it_expands_the_limits_of_the_range_if_midweek

    def test_that_it_expands_the_limits_of_the_range_if_midweek(self):
        range = WEEK.range(d_tz(2013, 4, 3), d_tz(2013, 4, 19))

        assert_that(list(range), contains(
            (d_tz(2013, 4, 1), d_tz(2013, 4, 8)),
            (d_tz(2013, 4, 8), d_tz(2013, 4, 15)),
            (d_tz(2013, 4, 15), d_tz(2013, 4, 22))
        ))
开发者ID:frabcus,项目名称:backdrop,代码行数:8,代码来源:test_timeseries.py


示例19: test_seconds_out_of_date_shows_correct_number_of_seconds_out_of_date

    def test_seconds_out_of_date_shows_correct_number_of_seconds_out_of_date(self):
        with freeze_time('2014-01-28'):
            # We expect it to be 0 seconds out of date
            self.setup_config({'max_age_expected': int(0)})

            # But it's a day out of date, so it should be 1day's worth of seconds out of date
            self.mock_storage.get_last_updated.return_value = d_tz(2014, 1, 27)
            assert_that(self.data_set.get_seconds_out_of_date(), is_(86400))

        with freeze_time('2014-01-28'):
            # We expect it to be a day out of date
            self.setup_config({'max_age_expected': int(86400)})

            self.mock_storage.get_last_updated.return_value = d_tz(2014, 1, 25)
            # It's three days out, so we should get 2 days past sell by date
            assert_that(self.data_set.get_seconds_out_of_date(), is_(172800))
开发者ID:NRCan,项目名称:backdrop,代码行数:16,代码来源:test_data_set.py


示例20: test_data_with__timestamp_gets_a__period_start_ats

    def test_data_with__timestamp_gets_a__period_start_ats(self):
        incoming_data = {
            'foo': 'bar',
            '_timestamp': d_tz(2013, 2, 2, 0, 0, 0)
        }
        some_record = Record(incoming_data)

        assert_that(
            some_record.meta["_week_start_at"],
            is_(d_tz(2013, 1, 28))
        )

        assert_that(
            some_record.meta["_month_start_at"],
            is_(d_tz(2013, 2, 1))
        )
开发者ID:frabcus,项目名称:backdrop,代码行数:16,代码来源:test_records.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python validity_matcher.is_invalid_with_message函数代码示例发布时间:2022-05-27
下一篇:
Python test_helpers.d函数代码示例发布时间: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