Exemple #1
0
 def test_arrow_support_eq(self):
     filter = DateTimeFilter(ArrowRecord.created_utc)
     filter.set('eq', '12/31/2010')
     self.assert_filter_query(
         filter,
         "WHERE arrow_records.created_utc BETWEEN '2010-12-31 00:00:00.000000' "
         "AND '2010-12-31 23:59:59.999999'")
Exemple #2
0
 def test_arrow_support_eq(self):
     filter = DateTimeFilter(ArrowRecord.created_utc)
     filter.set('eq', '12/31/2010')
     self.assert_filter_query(
         filter,
         "WHERE arrow_records.created_utc BETWEEN '2010-12-31 00:00:00.000000' "
         "AND '2010-12-31 23:59:59.999999'")
Exemple #3
0
 def test_days_ago(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 1))
     filter.set('da', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2011-12-22 00:00:00.000000' AND "
         "'2011-12-22 23:59:59.999999'")
Exemple #4
0
 def test_in_less_than_days(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('iltd', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts >= '2012-01-01 12:35:00.000000' AND "
         "persons.createdts < '2012-01-11 00:00:00.000000'")
Exemple #5
0
 def test_less_than_days_ago(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 1))
     filter.set('ltda', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts > '2011-12-22 23:59:59.999999' AND "
         "persons.createdts < '2012-01-01 00:00:00.000000'")
Exemple #6
0
 def test_in_days(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('ind', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-11 00:00:00.000000' AND "
         "'2012-01-11 23:59:59.999999'")
Exemple #7
0
 def test_today(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('today', None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-01 00:00:00.000000' AND "
         "'2012-01-01 23:59:59.999999'")
Exemple #8
0
 def test_this_week_right_edge(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 23, 59, 59, 999999))
     filter.set('thisweek', None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-01 00:00:00.000000' AND "
         "'2012-01-07 23:59:59.999999'")
Exemple #9
0
 def test_today(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('today', None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-01 00:00:00.000000' AND "
         "'2012-01-01 23:59:59.999999'")
Exemple #10
0
 def test_between_with_explicit_midnight(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('between', '1/31/2010 10:00', '12/31/2010 00:00')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2010-01-31 10:00:00.000000' AND "
         "'2010-12-31 00:00:00.000000'")
Exemple #11
0
 def test_this_week_right_edge(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 23, 59, 59, 999999))
     filter.set('thisweek', None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-01 00:00:00.000000' AND "
         "'2012-01-07 23:59:59.999999'")
Exemple #12
0
 def test_arrow_support_lastmonth(self):
     filter = DateTimeFilter(ArrowRecord.created_utc, _now=dt.datetime(2016, 7, 18))
     filter.set('lastmonth', None)
     self.assert_filter_query(
         filter,
         "WHERE arrow_records.created_utc BETWEEN '2016-06-01 00:00:00.000000' "
         "AND '2016-06-30 23:59:59.999999'")
Exemple #13
0
 def test_arrow_support_lastmonth(self):
     filter = DateTimeFilter(ArrowRecord.created_utc, _now=dt.datetime(2016, 7, 18))
     filter.set('lastmonth', None)
     self.assert_filter_query(
         filter,
         "WHERE arrow_records.created_utc BETWEEN '2016-06-01 00:00:00.000000' "
         "AND '2016-06-30 23:59:59.999999'")
Exemple #14
0
 def test_in_days(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('ind', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-11 00:00:00.000000' AND "
         "'2012-01-11 23:59:59.999999'")
Exemple #15
0
 def test_in_less_than_days(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('iltd', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts >= '2012-01-01 12:35:00.000000' AND "
         "persons.createdts < '2012-01-11 00:00:00.000000'")
Exemple #16
0
 def test_between_with_explicit_midnight(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('between', '1/31/2010 10:00', '12/31/2010 00:00')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2010-01-31 10:00:00.000000' AND "
         "'2010-12-31 00:00:00.000000'")
Exemple #17
0
 def test_less_than_days_ago(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 1))
     filter.set('ltda', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts > '2011-12-22 23:59:59.999999' AND "
         "persons.createdts < '2012-01-01 00:00:00.000000'")
Exemple #18
0
 def test_days_ago(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 1))
     filter.set('da', '10')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2011-12-22 00:00:00.000000' AND "
         "'2011-12-22 23:59:59.999999'")
Exemple #19
0
 def test_not_between(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!between', '1/31/2010', '12/31/2010')
     eq_(filter.error, False)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts NOT BETWEEN '2010-01-31 00:00:00.000000' AND "
         "'2010-12-31 23:59:59.999999'")
Exemple #20
0
 def test_not_eq(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!eq', '12/31/2010')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts NOT BETWEEN '2010-12-31 00:00:00.000000' AND "
         "'2010-12-31 23:59:59.999999'")
     eq_(filter.value1_set_with, '12/31/2010')
Exemple #21
0
 def test_default(self):
     filter = DateTimeFilter(Person.createdts, default_op='between', default_value1='1/31/2010',
                             default_value2='12/31/2010')
     filter.set(None, None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2010-01-31 00:00:00.000000' AND "
         "'2010-12-31 23:59:59.999999'")
Exemple #22
0
 def test_not_eq(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!eq', '12/31/2010')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts NOT BETWEEN '2010-12-31 00:00:00.000000' AND "
         "'2010-12-31 23:59:59.999999'")
     eq_(filter.value1_set_with, '12/31/2010')
Exemple #23
0
 def test_not_between(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!between', '1/31/2010', '12/31/2010')
     eq_(filter.error, False)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts NOT BETWEEN '2010-01-31 00:00:00.000000' AND "
         "'2010-12-31 23:59:59.999999'")
Exemple #24
0
 def test_default(self):
     filter = DateTimeFilter(Person.createdts, default_op='between', default_value1='1/31/2010',
                             default_value2='12/31/2010')
     filter.set(None, None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2010-01-31 00:00:00.000000' AND "
         "'2010-12-31 23:59:59.999999'")
Exemple #25
0
 def test_between_with_time(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('between', '1/31/2010 10:00', '12/31/2010 10:59:59')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2010-01-31 10:00:00.000000' AND "
         "'2010-12-31 10:59:59.000000'")
     eq_(filter.value1_set_with, '01/31/2010 10:00 AM')
     eq_(filter.value2_set_with, '12/31/2010 10:59 AM')
Exemple #26
0
 def test_this_year_default(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 2, 4), default_op='thisyear')
     filter.set(None, None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-01 00:00:00.000000' AND "
         "'2012-12-31 23:59:59.999999'"
     )
     eq_(filter.description, '01/01/2012 - 12/31/2012')
Exemple #27
0
 def test_between_with_time(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('between', '1/31/2010 10:00', '12/31/2010 10:59:59')
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2010-01-31 10:00:00.000000' AND "
         "'2010-12-31 10:59:59.000000'")
     eq_(filter.value1_set_with, '01/31/2010 10:00 AM')
     eq_(filter.value2_set_with, '12/31/2010 10:59 AM')
Exemple #28
0
 def test_this_year_default(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 2, 4), default_op='thisyear')
     filter.set(None, None)
     self.assert_filter_query(
         filter,
         "WHERE persons.createdts BETWEEN '2012-01-01 00:00:00.000000' AND "
         "'2012-12-31 23:59:59.999999'"
     )
     eq_(filter.description, '01/01/2012 - 12/31/2012')
Exemple #29
0
 def test_lte(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('lte', '12/31/2010')
     self.assert_filter_query(filter, "WHERE persons.createdts <= '2010-12-31 23:59:59.999999'")
     filter.set('lte', '12/31/2010', '')
     self.assert_filter_query(filter, "WHERE persons.createdts <= '2010-12-31 23:59:59.999999'")
     eq_(filter.value1_set_with, '12/31/2010')
     with assert_raises(formencode.Invalid):
         filter.set('lte', '')
Exemple #30
0
 def test_lte(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('lte', '12/31/2010')
     self.assert_filter_query(filter, "WHERE persons.createdts <= '2010-12-31 23:59:59.999999'")
     filter.set('lte', '12/31/2010', '')
     self.assert_filter_query(filter, "WHERE persons.createdts <= '2010-12-31 23:59:59.999999'")
     eq_(filter.value1_set_with, '12/31/2010')
     with assert_raises(formencode.Invalid):
         filter.set('lte', '')
Exemple #31
0
 def test_set_makes_op_none(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.op = 'foo'
     filter.set('', '')
     assert filter.op is None
Exemple #32
0
 def test_set_makes_op_none(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.op = 'foo'
     filter.set('', '')
     assert filter.op is None
Exemple #33
0
 def test_in_days_overflow(self):
     filter = DateTimeFilter(Person.due_date, _now=dt.date(2012, 1, 1))
     filter.set('ind', '10000000')
Exemple #34
0
 def test_in_more_than_days(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('imtd', '10')
     self.assert_filter_query(filter, "WHERE persons.createdts > '2012-01-11 23:59:59.999999'")
Exemple #35
0
 def test_more_than_days_ago(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 1))
     filter.set('mtda', '10')
     self.assert_filter_query(filter, "WHERE persons.createdts < '2011-12-22 00:00:00.000000'")
Exemple #36
0
 def test_not_eq_with_time(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!eq', '12/31/2010 10:26:27')
     self.assert_filter_query(filter, "WHERE persons.createdts != '2010-12-31 10:26:27.000000'")
Exemple #37
0
 def test_this_month(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 4))
     filter.set('thismonth', None)
     self.assert_filter_query(filter, self.between_sql)
     eq_(filter.description, '01/01/2012 - 01/31/2012')
Exemple #38
0
 def test_not_eq_with_time(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!eq', '12/31/2010 10:26:27')
     self.assert_filter_query(filter, "WHERE persons.createdts != '2010-12-31 10:26:27.000000'")
Exemple #39
0
 def test_in_more_than_days(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('imtd', '10')
     self.assert_filter_query(filter, "WHERE persons.createdts > '2012-01-11 23:59:59.999999'")
Exemple #40
0
 def test_selmonth(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 2, 4))
     filter.set('selmonth', 1, 2012)
     self.assert_filter_query(filter, self.between_sql)
     eq_(filter.description, 'Jan 2012')
Exemple #41
0
 def test_between_blank(self):
     filter = DateTimeFilter(Person.createdts)
     with assert_raises(formencode.Invalid):
         filter.set('between', '', '')
     eq_(filter.error, True)
     eq_(filter.description, 'invalid')
Exemple #42
0
 def test_gte(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('gte', '12/31/2010')
     self.assert_filter_query(filter, "WHERE persons.createdts >= '2010-12-31 00:00:00.000000'")
     eq_(filter.value1_set_with, '12/31/2010')
Exemple #43
0
 def test_not_empty(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!empty', None)
     self.assert_filter_query(filter, "WHERE persons.createdts IS NOT NULL")
     filter.set('!empty', '')
     self.assert_filter_query(filter, "WHERE persons.createdts IS NOT NULL")
Exemple #44
0
 def test_gte_with_time(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('gte', '12/31/2010 12:35')
     self.assert_filter_query(filter, "WHERE persons.createdts >= '2010-12-31 12:35:00.000000'")
Exemple #45
0
 def test_gte_with_time(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('gte', '12/31/2010 12:35')
     self.assert_filter_query(filter, "WHERE persons.createdts >= '2010-12-31 12:35:00.000000'")
Exemple #46
0
 def test_not_empty(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('!empty', None)
     self.assert_filter_query(filter, "WHERE persons.createdts IS NOT NULL")
     filter.set('!empty', '')
     self.assert_filter_query(filter, "WHERE persons.createdts IS NOT NULL")
Exemple #47
0
 def test_gte(self):
     filter = DateTimeFilter(Person.createdts)
     filter.set('gte', '12/31/2010')
     self.assert_filter_query(filter, "WHERE persons.createdts >= '2010-12-31 00:00:00.000000'")
     eq_(filter.value1_set_with, '12/31/2010')
Exemple #48
0
 def test_this_month(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 4))
     filter.set('thismonth', None)
     self.assert_filter_query(filter, self.between_sql)
     eq_(filter.description, '01/01/2012 - 01/31/2012')
Exemple #49
0
 def test_non_days_operator_with_empty_value(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('lastmonth', '')
Exemple #50
0
 def test_non_days_operator_with_empty_value(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.datetime(2012, 1, 1, 12, 35))
     filter.set('lastmonth', '')
Exemple #51
0
 def test_between_blank(self):
     filter = DateTimeFilter(Person.createdts)
     with assert_raises(formencode.Invalid):
         filter.set('between', '', '')
     eq_(filter.error, True)
     eq_(filter.description, 'invalid')
Exemple #52
0
 def test_last_month_right_edge(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 2, 29))
     filter.set('lastmonth', None)
     self.assert_filter_query(filter, self.between_sql)
     eq_(filter.description, '01/01/2012 - 01/31/2012')
Exemple #53
0
 def test_last_month_right_edge(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 2, 29))
     filter.set('lastmonth', None)
     self.assert_filter_query(filter, self.between_sql)
     eq_(filter.description, '01/01/2012 - 01/31/2012')
Exemple #54
0
 def test_more_than_days_ago(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 1, 1))
     filter.set('mtda', '10')
     self.assert_filter_query(filter, "WHERE persons.createdts < '2011-12-22 00:00:00.000000'")
Exemple #55
0
 def test_selmonth(self):
     filter = DateTimeFilter(Person.createdts, _now=dt.date(2012, 2, 4))
     filter.set('selmonth', 1, 2012)
     self.assert_filter_query(filter, self.between_sql)
     eq_(filter.description, 'Jan 2012')
Exemple #56
0
 def test_in_days_overflow(self):
     filter = DateTimeFilter(Person.due_date, _now=dt.date(2012, 1, 1))
     filter.set('ind', '10000000')