Example #1
0
        self.importer.run()
        self.assertEqual(len(self.lib.albums()), 2)
        self.assertIsNotNone(self.lib.albums('album:album 1').get())

    @unittest.skip('not working yet')
    @patch('beets.plugins.send')
    def test_resume_singleton(self, plugins_send):
        self.importer = self.create_importer(item_count=2)
        self.config['import']['resume'] = True
        self.config['import']['singletons'] = True

        def raise_exception(event, **kwargs):
            if event == 'item_imported':
                raise importer.ImportAbort
        plugins_send.side_effect = raise_exception

        self.importer.run()
        self.assertEqual(len(self.lib.items()), 1)
        self.assertIsNotNone(self.lib.items('title:track 0').get())

        self.importer.run()
        self.assertEqual(len(self.lib.items()), 2)
        self.assertIsNotNone(self.lib.items('title:track 1').get())


def suite():
    return unittest.TestLoader().loadTestsFromName(__name__)

if __name__ == '__main__':
    unittest.main(defaultTest='suite')
Example #2
0
                                       white_p))
        artist_p = []
        album_p = 'tribute christmas test'.split()
        self.assertTrue(
            IHatePlugin.do_i_hate_this(task, genre_p, artist_p, album_p,
                                       white_p))
        album_p = []
        white_p = 'goodband test\sartist another_band'.split()
        genre_p = 'some_genre test\sgenre'.split()
        self.assertFalse(
            IHatePlugin.do_i_hate_this(task, genre_p, artist_p, album_p,
                                       white_p))
        genre_p = []
        artist_p = 'bad_artist test\sartist'
        self.assertFalse(
            IHatePlugin.do_i_hate_this(task, genre_p, artist_p, album_p,
                                       white_p))
        artist_p = []
        album_p = 'tribute christmas test'.split()
        self.assertFalse(
            IHatePlugin.do_i_hate_this(task, genre_p, artist_p, album_p,
                                       white_p))


def suite():
    return unittest.TestLoader().loadTestsFromName(__name__)


if __name__ == '__main__':
    unittest.main(defaultTest='suite')
Example #3
0
    self.assertEqual(s.rank('low'), 0) # should be at the top again
    self.assertEqual(s.score('low'), -1.0) # verify score
    self.assertEqual(s.rank('high'), 1001) # should be last again
    self.assertEqual(s.score('high'), 1.1) # verify score
    for i in range(0, 1000):
      self.assertIsNotNone(s.rank(i))
      self.assertIsNotNone(s.score(i))
    # remove 1 from the back
    s.remrevrange(0, 1)
    self.assertEqual(s.count(), 1001)
    self.assertIsNone(s.rank('high')) # verify None
    self.assertIsNone(s.score('high')) # verify None

    # remove 499 from the back
    s.remrevrange(0, 499)
    self.assertEqual(s.count(), 502)
    self.assertEqual(s.rank('low'), 0) # should be at the top again
    self.assertEqual(s.score('low'), -1.0) # verify score


def suite():
  tests = unittest.TestLoader().loadTestsFromName(__name__)
  tests.addTests(doctest.DocTestSuite('yampdqmgr.sortedset'))
  return tests

if __name__ == '__main__':
  unittest.main(defaultTest='suite', verbosity=2)

# vim: set ai ts=2 sw=2 sts=2 expandtab:
# eof
Example #4
0
        res = importer._item_duplicate_check(self.lib, self._item_task(True, "xxx", "yyy"))
        self.assertFalse(res)

    def test_duplicate_album_existing(self):
        res = importer._duplicate_check(self.lib, self._album_task(False, existing=True))
        self.assertFalse(res)

    def test_duplicate_item_existing(self):
        res = importer._item_duplicate_check(self.lib, self._item_task(False, existing=True))
        self.assertFalse(res)


class TagLogTest(unittest.TestCase):
    def test_tag_log_line(self):
        sio = StringIO.StringIO()
        importer.tag_log(sio, "status", "path")
        assert "status path" in sio.getvalue()

    def test_tag_log_unicode(self):
        sio = StringIO.StringIO()
        importer.tag_log(sio, "status", "caf\xc3\xa9")
        assert "status caf" in sio.getvalue()


def suite():
    return unittest.TestLoader().loadTestsFromName(__name__)


if __name__ == "__main__":
    unittest.main(defaultTest="suite")
Example #5
0
        c.min_cache(1000)
        c.max_cache(1000)
        self.assertEqual(c.cache_size(), 10)

    def test_cache_size_2(self):
        c = Cache(1000, 1000)
        self.assertEqual(c.cache_size(), 0)
        for i in range(0, 1000):
            self.assertEqual(c.get(i), None)
            self.assertFalse(c.has_key(i))
            c.set(i, i)
            self.assertEqual(c.get(i), i)
            self.assertTrue(c.has_key(i))
        self.assertEqual(c.cache_size(), 1000)
        for i in range(0, 1000):
            self.assertTrue(c.has_key(i))
            self.assertEqual(c.get(i), i)


def suite():
    tests = unittest.TestLoader().loadTestsFromName(__name__)
    tests.addTests(doctest.DocTestSuite("yampdqmgr.cache"))
    return tests


if __name__ == "__main__":
    unittest.main(defaultTest="suite", verbosity=2)

# vim: set ai ts=2 sw=2 sts=2 expandtab:
# eof