mirror of
https://github.com/beetbox/beets.git
synced 2025-12-16 05:34:47 +01:00
info: add unit tests
* Add tests for length (human/raw, library/path) and custom format.
This commit is contained in:
parent
8d9db9ffe6
commit
67af8af7dd
1 changed files with 38 additions and 0 deletions
|
|
@ -107,6 +107,44 @@ class InfoTest(unittest.TestCase, TestHelper):
|
|||
self.assertNotIn(u'title:', out)
|
||||
self.assertIn(u'album: xxxx', out)
|
||||
|
||||
def test_length_human_library(self):
|
||||
item, = self.add_item_fixtures()
|
||||
item.album = 'loool'
|
||||
item.length = 123.4
|
||||
item.write()
|
||||
item.store()
|
||||
|
||||
out = self.run_with_output('--library')
|
||||
self.assertIn(u'length: 2:03', out)
|
||||
|
||||
def test_length_raw_library(self):
|
||||
item, = self.add_item_fixtures()
|
||||
item.album = 'loool'
|
||||
item.length = 123.4
|
||||
item.write()
|
||||
item.store()
|
||||
|
||||
out = self.run_with_output('--library', '--raw-length')
|
||||
self.assertIn(u'length: 123.4', out)
|
||||
|
||||
def test_length_human_path(self):
|
||||
path = self.create_mediafile_fixture()
|
||||
out = self.run_with_output(path)
|
||||
self.assertIn(u'length: 0:01', out)
|
||||
self.remove_mediafile_fixtures()
|
||||
|
||||
def test_length_raw_path(self):
|
||||
path = self.create_mediafile_fixture()
|
||||
out = self.run_with_output(path, '--raw-length')
|
||||
self.assertIn(u'length: 1.071', out)
|
||||
self.remove_mediafile_fixtures()
|
||||
|
||||
def test_custom_format(self):
|
||||
self.add_item_fixtures()
|
||||
out = self.run_with_output('--library', '--format',
|
||||
'$track. $title - $artist ($length)')
|
||||
self.assertEqual(u'02. tïtle 0 - the artist (0:01)\n', out)
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue