def test_that_periodic_queries_are_allowed(self):
     validation_result = validate_request_args({
         'period': 'day',
         'start_at': '2012-11-01T00:00:00Z',
         'end_at': '2012-12-01T00:00:00Z',
     })
     assert_that(validation_result, is_valid())
Exemple #2
0
 def test_queries_with_sort_by_and_period_and_group_by_are_allowed(self):
     validation_result = validate_request_args({
         "sort_by": "foo:ascending",
         "period": "week",
         "group_by": "foo"
     })
     assert_that( validation_result, is_valid() )
 def test_that_querying_for_more_than_7_days_of_data_is_allowed(self):
     validation_result = validate_request_args({
         'period': 'week',
         'start_at': '2013-04-01T00:00:00Z',
         'end_at': '2013-04-15T00:00:00Z'
     })
     assert_that(validation_result, is_valid())
 def test_that_period_query_with_monday_limits_is_allowed(self):
     validation_result = validate_request_args({
         'period': 'week',
         'start_at': '2013-04-01T00:00:00Z',
         'end_at': '2013-04-08T00:00:00Z'
     })
     assert_that(validation_result, is_valid())
 def test_that_query_ending_on_midnight_is_allowed(self):
     result = validate_request_args({
         'group_by': 'some_key',
         'start_at': '2013-01-24T00:00:00+00:00',
         'end_at': '2013-01-31T00:00:00+00:00'
     })
     assert_that(result, is_valid())
Exemple #6
0
 def test_queries_with_will_formatted_starts_and_ends_are_allowed(self):
     validation_result = validate_request_args({
         'period': 'week',
         'start_at': '2010-01-01T00:10:10+00:00',
         'end_at': '2010-01-07T00:10:10+00:00',
     })
     assert_that( validation_result, is_valid() )
Exemple #7
0
    def test_period_with_just_positive_duration(self):
        validation_result = validate_request_args({
            'period': 'day',
            'duration': '3',
        })

        assert_that(validation_result, is_valid())
Exemple #8
0
 def test_that_inclusive_queries(self):
     validation_result = validate_request_args({
         'inclusive': 'true',
         'start_at': '2012-12-01T00:00:00Z',
         'end_at': '2012-12-01T00:00:00Z',
     })
     assert_that(validation_result, is_valid())
 def test_queries_with_sort_by_and_period_and_group_by_are_allowed(self):
     validation_result = validate_request_args({
         "sort_by": "foo:ascending",
         "period": "week",
         "group_by": "foo"
     })
     assert_that(validation_result, is_valid())
Exemple #10
0
 def test_queries_with_dates_at_beginning_of_day_are_allowed(self):
     validation_result = validate_request_args({
         'period': 'day',
         'start_at': '2000-02-02T00:00:00+00:00',
         'end_at': '2000-02-19T00:00:00+00:00'
     }, False)
     assert_that(validation_result, is_valid())
Exemple #11
0
 def test_queries_for_hour_period_with_dates_at_middle_of_day_are_allowed(self):
     validation_result = validate_request_args({
         'period': 'hour',
         'start_at': '2000-02-02T12:00:00+00:00',
         'end_at': '2000-02-19T13:00:00+00:00'
     }, False)
     assert_that(validation_result, is_valid())
Exemple #12
0
 def test_that_query_ending_on_midnight_is_allowed(self):
     result = validate_request_args({
         'group_by': 'some_key',
         'start_at': '2013-01-24T00:00:00+00:00',
         'end_at': '2013-01-31T00:00:00+00:00'
     })
     assert_that(result, is_valid())
Exemple #13
0
 def test_queries_for_hour_period_spanning_less_than_seven_days_are_allowed(self):
     validation_result = validate_request_args({
         'period': 'hour',
         'start_at': '2000-02-02T00:00:00+00:00',
         'end_at': '2000-02-08T00:00:00+00:00'
     }, False)
     assert_that(validation_result, is_valid())
 def test_queries_with_well_formatted_end_at_are_allowed(self):
     validation_result = validate_request_args({
         'start_at':
         '2000-02-02T00:02:02+00:00',
         'end_at':
         '2000-02-09T00:02:02+00:00'
     })
     assert_that(validation_result, is_valid())
    def test_that_queries_which_are_midnight_and_not_utc_are_allowed(self):
        validation_result = validate_request_args({
            'group_by': 'some_key',
            'start_at': '2013-04-01T04:30:00+04:30',
            'end_at': '2013-04-08T00:00:00+00:00'
        })

        assert_that(validation_result, is_valid())
    def test_that_grouping_by_month_with_dates_on_the_1st_is_allowed(self):
        validation_result = validate_request_args({
            "period": "month",
            "start_at": "2013-01-01T00:00:00Z",
            "end_at": "2014-01-01T00:00:00Z"
        })

        assert_that(validation_result, is_valid())
Exemple #17
0
    def test_period_with_start_at_and_duration(self):
        validation_result = validate_request_args({
            'period': 'day',
            'start_at': '2000-02-02T00:00:00+00:00',
            'duration': '3',
        })

        assert_that(validation_result, is_valid())
Exemple #18
0
 def test_that_querying_for_more_than_7_days_of_data_is_allowed(self):
     validation_result = validate_request_args({
         'period':
         'week',
         'start_at':
         '2013-04-01T00:00:00Z',
         'end_at':
         '2013-04-15T00:00:00Z'
     })
     assert_that(validation_result, is_valid())
Exemple #19
0
    def test_that_collect_queries_with_valid_methods_are_allowed(self):
        valid_collection_methods = ["sum", "count", "set", "mean"]

        for method in valid_collection_methods:
            validation_result = validate_request_args({
                'group_by': 'foo',
                'collect': 'field:{0}'.format(method),
            })

            assert_that(validation_result, is_valid())
Exemple #20
0
 def test_that_period_query_with_monday_limits_is_allowed(self):
     validation_result = validate_request_args({
         'period':
         'week',
         'start_at':
         '2013-04-01T00:00:00Z',
         'end_at':
         '2013-04-08T00:00:00Z'
     })
     assert_that(validation_result, is_valid())
Exemple #21
0
 def test_that_periodic_queries_are_allowed(self):
     validation_result = validate_request_args({
         'period':
         'day',
         'start_at':
         '2012-11-01T00:00:00Z',
         'end_at':
         '2012-12-01T00:00:00Z',
     })
     assert_that(validation_result, is_valid())
 def test_queries_with_will_formatted_starts_and_ends_are_allowed(self):
     validation_result = validate_request_args({
         'period':
         'week',
         'start_at':
         '2010-01-01T00:10:10+00:00',
         'end_at':
         '2010-01-07T00:10:10+00:00',
     })
     assert_that(validation_result, is_valid())
Exemple #23
0
    def test_that_queries_which_are_midnight_and_not_utc_are_allowed(self):
        validation_result = validate_request_args({
            'group_by':
            'some_key',
            'start_at':
            '2013-04-01T04:30:00+04:30',
            'end_at':
            '2013-04-08T00:00:00+00:00'
        })

        assert_that(validation_result, is_valid())
Exemple #24
0
    def test_that_grouping_by_month_with_dates_on_the_1st_is_allowed(self):
        validation_result = validate_request_args({
            "period":
            "month",
            "start_at":
            "2013-01-01T00:00:00Z",
            "end_at":
            "2014-01-01T00:00:00Z"
        })

        assert_that(validation_result, is_valid())
    def test_that_collect_queries_with_valid_methods_are_allowed(self):
        valid_collection_methods = ["sum", "count", "set", "mean"]

        for method in valid_collection_methods:
            validation_result = validate_request_args({
                'group_by':
                'foo',
                'collect':
                'field:{0}'.format(method),
            })

            assert_that(validation_result, is_valid())
 def test_queries_with_collect_and_group_by_are_allowed(self):
     validation_result_with_group_by = validate_request_args(
         MultiDict([("collect", 'foo'), ("group_by", 'bar')]))
     assert_that(validation_result_with_group_by, is_valid())
    def test_known_internal_fields_are_recognised_as_valid(self):
        validate = validate_record_data

        assert_that(validate({'_timestamp': valid_timestamp}), is_valid())
        assert_that(validate({'_id': valid_string}), is_valid())
 def test_queries_without_code_injection_collect_values_are_allowed(self):
     validation_result_without_group_by = validate_request_args(
         MultiDict([("group_by", 'bar'), ("collect", 'a_aAbBzZ_')]))
     assert_that(validation_result_without_group_by, is_valid())
Exemple #29
0
 def test_queries_without_code_injection_collect_values_are_allowed(self):
     validation_result_without_group_by = validate_request_args(MultiDict([
         ("group_by", 'bar'),
         ("collect", 'a_aAbBzZ_')
     ]))
     assert_that(validation_result_without_group_by, is_valid())
Exemple #30
0
 def test_queries_with_collect_and_group_by_are_allowed(self):
     validation_result_with_group_by = validate_request_args(MultiDict([
         ("collect", 'foo'),
         ("group_by", 'bar')
     ]))
     assert_that(validation_result_with_group_by, is_valid())
Exemple #31
0
 def test_queries_with_positive_integer_limit_values_are_allowed(self):
     validation_result = validate_request_args({
         'limit': '3'
     })
     assert_that( validation_result, is_valid() )
Exemple #32
0
 def test_queries_with_sort_by_descending_are_allowed(self):
     validation_result = validate_request_args({
         'sort_by': 'foo:descending',
     })
     assert_that( validation_result, is_valid() )
Exemple #33
0
 def test_allow_none_value(self):
     validation_result = validate_record_data({
         'none_is_fine': None
     })
     assert_that(validation_result, is_valid())
 def test_allow_none_value(self):
     validation_result = validate_record_data({'none_is_fine': None})
     assert_that(validation_result, is_valid())
 def test_queries_with_sort_by_descending_are_allowed(self):
     validation_result = validate_request_args({
         'sort_by': 'foo:descending',
     })
     assert_that(validation_result, is_valid())
Exemple #36
0
 def test_queries_with_well_formatted_end_at_are_allowed(self):
     validation_result = validate_request_args({
         'start_at': '2000-02-02T00:02:02+00:00',
         'end_at': '2000-02-09T00:02:02+00:00'
     })
     assert_that(validation_result, is_valid())
Exemple #37
0
 def test_that_grouped_queries_are_allowed(self):
     validation_result = validate_request_args({'group_by': 'some_key'})
     assert_that(validation_result, is_valid())
 def test_that_periodic_queries_are_allowed(self):
     validation_result = validate_request_args({'period': 'week'})
     assert_that(validation_result, is_valid())
 def test_queries_with_positive_integer_limit_values_are_allowed(self):
     validation_result = validate_request_args({'limit': '3'})
     assert_that(validation_result, is_valid())
 def test_queries_with_well_formatted_filter_by_are_allowed(self):
     validation_result = validate_request_args(
         MultiDict([('filter_by', 'foo:bar')]))
     assert_that(validation_result, is_valid())
 def test_that_grouped_queries_are_allowed(self):
     validation_result = validate_request_args({'group_by': 'some_key'})
     assert_that(validation_result, is_valid())
Exemple #42
0
    def test_known_internal_fields_are_recognised_as_valid(self):
        validate = validate_record_data

        assert_that(validate({'_timestamp': valid_timestamp}), is_valid())
        assert_that(validate({'_id': valid_string}), is_valid())
Exemple #43
0
 def test_queries_with_well_formatted_filter_by_are_allowed(self):
     validation_result = validate_request_args(MultiDict([
         ('filter_by', 'foo:bar')
     ]))
     assert_that(validation_result, is_valid())
Exemple #44
0
 def test_that_periodic_queries_are_allowed(self):
     validation_result = validate_request_args({'period': 'week'})
     assert_that(validation_result, is_valid())