Exemplo n.º 1
0
 def test_invalid_date_query(self):
     q_list = [
         '2001-01-0a', '2001-0a', '200a', '2001-01-01..2001-01-0a',
         '2001-0a..2001-01', '200a..2002', '20aa..', '..2aa'
     ]
     for q in q_list:
         with self.assertRaises(InvalidQueryArgumentValueError):
             DateQuery('added', q)
Exemplo n.º 2
0
 def test_start_relative(self):
     for timespan in ['d', 'w', 'm', 'y']:
         query = DateQuery('added', '-4' + timespan + '..')
         matched = self.lib.items(query)
         self.assertEqual(len(matched), 1)
Exemplo n.º 3
0
 def test_single_month_nonmatch_slow(self):
     query = DateQuery('added', (datetime.now() + timedelta(days=30))
                       .strftime('%Y-%m'))
     self.assertFalse(query.match(self.i))
Exemplo n.º 4
0
 def test_single_month_nonmatch_slow(self):
     query = DateQuery('added', '2013-04')
     self.assertFalse(query.match(self.i))
Exemplo n.º 5
0
 def test_datetime_space_separator(self):
     date_query = DateQuery('added', '2000-01-01 12')
     self.assertEqual(date_query.interval.start, datetime(2000, 1, 1, 12))
     self.assertEqual(date_query.interval.end, datetime(2000, 1, 1, 13))
Exemplo n.º 6
0
 def test_too_many_components(self):
     with self.assertRaises(InvalidQueryArgumentValueError):
         DateQuery('added', '12-34-56-78')
Exemplo n.º 7
0
 def test_single_hour_nonmatch_slow(self):
     query = DateQuery('added',
                       (self._now +
                        timedelta(hours=1)).strftime('%Y-%m-%d %H:%M'))
     self.assertFalse(query.match(self.i))
Exemplo n.º 8
0
 def test_single_hour_nonmatch_fast(self):
     query = DateQuery('added',
                       (self._now +
                        timedelta(hours=1)).strftime('%Y-%m-%d %H:%M'))
     matched = self.lib.items(query)
     self.assertEqual(len(matched), 0)
Exemplo n.º 9
0
 def test_single_month_nonmatch_slow(self):
     query = DateQuery('added', '2013-04')
     self.assertFalse(query.match(self.i))
Exemplo n.º 10
0
 def test_single_month_match_slow(self):
     query = DateQuery('added', '2013-03')
     self.assertTrue(query.match(self.i))
Exemplo n.º 11
0
 def test_single_month_match_fast(self):
     query = DateQuery('added', '2013-03')
     matched = self.lib.items(query)
     self.assertEqual(len(matched), 1)
Exemplo n.º 12
0
 def test_too_many_components(self):
     DateQuery('added', '12-34-56-78')
Exemplo n.º 13
0
 def test_long_numbers(self):
     DateQuery('added', '1409830085..1412422089')
Exemplo n.º 14
0
 def test_single_day_nonmatch_fast(self):
     query = DateQuery('added', (datetime.now() + timedelta(days=1))
                       .strftime('%Y-%m-%d'))
     matched = self.lib.items(query)
     self.assertEqual(len(matched), 0)
Exemplo n.º 15
0
 def test_single_day_match_fast(self):
     query = DateQuery('added', datetime.now().strftime('%Y-%m-%d'))
     matched = self.lib.items(query)
     self.assertEqual(len(matched), 1)
Exemplo n.º 16
0
 def test_end_relative_fail(self):
     for timespan in ['d', 'w', 'm', 'y']:
         query = DateQuery('added', '..-4' + timespan)
         matched = self.lib.items(query)
         self.assertEqual(len(matched), 0)
Exemplo n.º 17
0
 def test_single_hour_match_fast(self):
     query = DateQuery('added', self._now.strftime('%Y-%m-%d %H:%M'))
     matched = self.lib.items(query)
     self.assertEqual(len(matched), 1)
Exemplo n.º 18
0
 def test_single_hour_match_slow(self):
     query = DateQuery('added', '2013-03-30 22')
     self.assertTrue(query.match(self.i))
Exemplo n.º 19
0
 def test_single_hour_match_slow(self):
     query = DateQuery('added', self._now.strftime('%Y-%m-%d %H:%M'))
     self.assertTrue(query.match(self.i))
Exemplo n.º 20
0
 def test_single_hour_nonmatch_fast(self):
     query = DateQuery('added', '2013-03-30 21')
     matched = self.lib.items(query)
     self.assertEqual(len(matched), 0)
Exemplo n.º 21
0
 def test_long_numbers(self):
     with self.assertRaises(InvalidQueryArgumentValueError):
         DateQuery('added', '1409830085..1412422089')
Exemplo n.º 22
0
 def test_single_hour_nonmatch_slow(self):
     query = DateQuery('added', '2013-03-30 21')
     self.assertFalse(query.match(self.i))
Exemplo n.º 23
0
 def test_single_month_nonmatch_fast(self):
     query = DateQuery('added',
                       (self._now + timedelta(days=30)).strftime('%Y-%m'))
     matched = self.lib.items(query)
     self.assertEqual(len(matched), 0)
Exemplo n.º 24
0
 def test_single_month_match_slow(self):
     query = DateQuery('added', self._now.strftime('%Y-%m'))
     self.assertTrue(query.match(self.i))
Exemplo n.º 25
0
 def test_datetime_invalid_separator(self):
     with self.assertRaises(InvalidQueryArgumentValueError):
         DateQuery('added', '2000-01-01x12')
Exemplo n.º 26
0
 def test_single_month_nonmatch_slow(self):
     query = DateQuery('added',
                       (self._now + timedelta(days=30)).strftime('%Y-%m'))
     self.assertFalse(query.match(self.i))
Exemplo n.º 27
0
 def test_single_month_match_slow(self):
     query = DateQuery('added', '2013-03')
     self.assertTrue(query.match(self.i))
Exemplo n.º 28
0
 def test_single_month_match_slow(self):
     query = DateQuery('added', datetime.now().strftime('%Y-%m'))
     self.assertTrue(query.match(self.i))