Esempio n. 1
0
 def test_get_formatted_none(self):
     with _common.platform_posix():
         self.i.some_other_field = None
         val = self.i._get_formatted('some_other_field')
     self.assertEqual(val, u'')
Esempio n. 2
0
 def test_get_formatted_pads_with_zero(self):
     with _common.platform_posix():
         self.i.track = 1
         name = self.i._get_formatted('track')
     self.assertTrue(name.startswith('0'))
Esempio n. 3
0
 def test_get_formatted_uses_khz_samplerate(self):
     with _common.platform_posix():
         self.i.samplerate = 12345
         val = self.i._get_formatted('samplerate')
     self.assertEqual(val, u'12kHz')
Esempio n. 4
0
 def test_truncate_unicode(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh', 4)
     self.assertEqual(p, u'abcd/fgh')
Esempio n. 5
0
 def test_sanitize_unix_replaces_leading_dot(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'one/.two/three')
     self.assertFalse('.' in p)
Esempio n. 6
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, '/base/' + dest)
Esempio n. 7
0
 def test_sanitize_empty_component(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo//bar', [
             (re.compile(ur'^$'), u'_'),
         ])
     self.assertEqual(p, u'foo/_/bar')
Esempio n. 8
0
 def test_sanitize_empty_component(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo//bar', [
             (re.compile(ur'^$'), u'_'),
         ])
     self.assertEqual(p, u'foo/_/bar')
Esempio n. 9
0
 def test_sanitize_unix_replaces_leading_dot(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'one/.two/three')
     self.assertFalse('.' in p)
Esempio n. 10
0
 def test_component_sanitize_datetime(self):
     with _common.platform_posix():
         val = beets.dbcore.format_for_path(1368302461.210265, 'added')
     self.assertTrue(val.startswith('2013'))
Esempio n. 11
0
 def test_component_sanitize_none(self):
     with _common.platform_posix():
         val = beets.dbcore.format_for_path(None, 'foo')
     self.assertEqual(val, u'')
Esempio n. 12
0
 def test_component_sanitize_uses_khz_samplerate(self):
     with _common.platform_posix():
         val = beets.dbcore.format_for_path(12345, 'samplerate')
     self.assertEqual(val, u'12kHz')
Esempio n. 13
0
 def test_component_sanitize_pads_with_zero(self):
     with _common.platform_posix():
         name = beets.dbcore.format_for_path(1, 'track')
     self.assertTrue(name.startswith('0'))
Esempio n. 14
0
 def test_component_sanitize_does_not_replace_separators(self):
     with _common.platform_posix():
         name = os.path.join('a', 'b')
         newname = beets.dbcore.format_for_path(name)
     self.assertEqual(name, newname)
Esempio n. 15
0
 def test_sanitize_with_custom_replace_overrides_built_in_sub(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'a/.?/b', [
             (re.compile(ur'foo'), u'bar'),
         ])
     self.assertEqual(p, u'a/.?/b')
Esempio n. 16
0
 def test_get_formatted_does_not_replace_separators(self):
     with _common.platform_posix():
         name = os.path.join('a', 'b')
         self.i.title = name
         newname = self.i.formatted().get('title')
     self.assertEqual(name, newname)
Esempio n. 17
0
 def _assert_dest(self, dest, i=None):
     if i is None:
         i = self.i
     with _common.platform_posix():
         actual = i.destination()
     self.assertEqual(actual, dest)
Esempio n. 18
0
 def test_get_formatted_pads_with_zero(self):
     with _common.platform_posix():
         self.i.track = 1
         name = self.i.formatted().get('track')
     self.assertTrue(name.startswith('0'))
Esempio n. 19
0
 def test_truncate_unicode(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh', 4)
     self.assertEqual(p, u'abcd/fgh')
Esempio n. 20
0
 def test_get_formatted_uses_kbps_bitrate(self):
     with _common.platform_posix():
         self.i.bitrate = 12345
         val = self.i.formatted().get('bitrate')
     self.assertEqual(val, u'12kbps')
Esempio n. 21
0
 def test_truncate_bytestring(self):
     with _common.platform_posix():
         p = util.truncate_path('abcde/fgh', 4)
     self.assertEqual(p, 'abcd/fgh')
Esempio n. 22
0
 def test_get_formatted_uses_khz_samplerate(self):
     with _common.platform_posix():
         self.i.samplerate = 12345
         val = self.i.formatted().get('samplerate')
     self.assertEqual(val, u'12kHz')
Esempio n. 23
0
 def test_truncate_preserves_extension(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh.ext', 5)
     self.assertEqual(p, u'abcde/f.ext')
Esempio n. 24
0
 def test_get_formatted_datetime(self):
     with _common.platform_posix():
         self.i.added = 1368302461.210265
         val = self.i.formatted().get('added')
     self.assertTrue(val.startswith('2013'))
Esempio n. 25
0
 def test_get_formatted_does_not_replace_separators(self):
     with _common.platform_posix():
         name = os.path.join('a', 'b')
         self.i.title = name
         newname = self.i._get_formatted('title')
     self.assertEqual(name, newname)
Esempio n. 26
0
 def test_get_formatted_none(self):
     with _common.platform_posix():
         self.i.some_other_field = None
         val = self.i.formatted().get('some_other_field')
     self.assertEqual(val, u'')
Esempio n. 27
0
 def test_get_formatted_uses_kbps_bitrate(self):
     with _common.platform_posix():
         self.i.bitrate = 12345
         val = self.i._get_formatted('bitrate')
     self.assertEqual(val, u'12kbps')
Esempio n. 28
0
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
Esempio n. 29
0
 def test_get_formatted_datetime(self):
     with _common.platform_posix():
         self.i.added = 1368302461.210265
         val = self.i._get_formatted('added')
     self.assertTrue(val.startswith('2013'))
Esempio n. 30
0
 def test_sanitize_with_custom_replace_overrides_built_in_sub(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'a/.?/b', [
             (re.compile(ur'foo'), u'bar'),
         ])
     self.assertEqual(p, u'a/.?/b')
Esempio n. 31
0
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
Esempio n. 32
0
 def test_sanitize_with_custom_replace_adds_replacements(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo/bar', [
             (re.compile(ur'foo'), u'bar'),
         ])
     self.assertEqual(p, u'bar/bar')
Esempio n. 33
0
 def test_sanitize_with_custom_replace_adds_replacements(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo/bar', [
             (re.compile(ur'foo'), u'bar'),
         ])
     self.assertEqual(p, u'bar/bar')
Esempio n. 34
0
 def _assert_dest(self, dest, i=None):
     if i is None:
         i = self.i
     with _common.platform_posix():
         actual = i.destination()
     self.assertEqual(actual, dest)
Esempio n. 35
0
 def test_syspath_posix_unchanged(self):
     with _common.platform_posix():
         path = os.path.join('a', 'b', 'c')
         outpath = util.syspath(path)
     self.assertEqual(path, outpath)
Esempio n. 36
0
 def test_syspath_posix_unchanged(self):
     with _common.platform_posix():
         path = os.path.join('a', 'b', 'c')
         outpath = util.syspath(path)
     self.assertEqual(path, outpath)
Esempio n. 37
0
 def test_truncate_bytestring(self):
     with _common.platform_posix():
         p = util.truncate_path('abcde/fgh', 4)
     self.assertEqual(p, 'abcd/fgh')
Esempio n. 38
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, '/base/' + dest)
Esempio n. 39
0
 def test_truncate_preserves_extension(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh.ext', 5)
     self.assertEqual(p, u'abcde/f.ext')
Esempio n. 40
0
 def test_component_sanitize_uses_kbps_bitrate(self):
     with _common.platform_posix():
         val = beets.library.format_for_path(12345, 'bitrate')
     self.assertEqual(val, u'12kbps')