Ejemplo n.º 1
0
 def test_numexpr_func(self):
     time = 424242
     col = Collection()
     col.songs = (AudioFile({'~#added': 400000, '~#length': 315}),
                  AudioFile({'~#added': 405000, '~#length': 225}))
     self.failUnless(NumexprTag('length:avg').evaluate(col, time, True)
                     == 270)
     self.failUnless(NumexprTag('added:max').evaluate(col, time, True)
                     == 19242)
Ejemplo n.º 2
0
 def test_date_tag(self):
     song = AudioFile({'date': '2012-11-09'})
     self.failUnless(NumexprTag('date').evaluate(song, 0, True)
                     == parse_date('2012-11-09'))
     self.failUnless(NumexprTag('date').evaluate(song, 424242, True)
                     == parse_date('2012-11-09'))
     self.failUnless(NumexprTag('date').evaluate(song, 0, True)
                     > parse_date('2012-11-08'))
     self.failUnless(NumexprTag('date').evaluate(song, 0, True)
                     < parse_date('2012-11-10'))
Ejemplo n.º 3
0
 def test_time_tag(self):
     time = 424242
     song = AudioFile({'~#added': 400000, '~#mtime': 410000,
                       '~#length': 315})
     self.failUnless(NumexprTag('added').evaluate(song, time, True)
                     == 24242)
     self.failUnless(NumexprTag('length').evaluate(song, time, True) == 315)
     self.failUnless(NumexprTag('date').evaluate(song, time, True) is None)
     self.failUnless(NumexprTag('added').evaluate(song, time, True)
                     > NumexprTag('mtime').evaluate(song, time, True))
Ejemplo n.º 4
0
 def test_numexpr_now(self):
     time = 424242
     day = 24 * 60 * 60
     self.failUnless(NumexprNow().evaluate(None, time, True) == time)
     self.failUnless(NumexprNow(day).evaluate(None, time, True)
                     == time - day)
     self.failUnless(NumexprNow().evaluate(None, time, True) ==
                     numexprTagOrSpecial('now').evaluate(None, time, True))
     self.failUnless(NumexprNow(day).evaluate(None, time, True) ==
                     numexprTagOrSpecial('today')
                     .evaluate(None, time, True))
     self.failUnless(NumexprNow().__repr__()
                     == numexprTagOrSpecial('now').__repr__())
     self.failUnless(NumexprTag('genre').__repr__()
                     == numexprTagOrSpecial('genre').__repr__())