Example #1
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'))
Example #2
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)
Example #3
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')
Example #4
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'))
Example #5
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)
Example #6
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)
Example #7
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')
Example #8
0
 def test_sanitize_with_custom_replace_adds_replacements(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo/bar', [
             (re.compile(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'bar/bar')
Example #9
0
 def test_sanitize_empty_component(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo//bar', [
             (re.compile(r'^$'), u'_'),
         ])
     self.assertEqual(p, u'foo/_/bar')
Example #10
0
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
Example #11
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(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'a/.?/b')
Example #12
0
 def test_sanitize_unix_replaces_leading_dot(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'one/.two/three')
     self.assertFalse(u'.' in p)
Example #13
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')
Example #14
0
 def test_truncate_unicode(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh', 4)
     self.assertEqual(p, u'abcd/fgh')
Example #15
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)
Example #16
0
 def test_syspath_posix_unchanged(self):
     with _common.platform_posix():
         path = os.path.join(u'a', u'b', u'c')
         outpath = util.syspath(path)
     self.assertEqual(path, outpath)
Example #17
0
 def test_truncate_bytestring(self):
     with _common.platform_posix():
         p = util.truncate_path(b'abcde/fgh', 4)
     self.assertEqual(p, b'abcd/fgh')
Example #18
0
 def test_truncate_bytestring(self):
     with _common.platform_posix():
         p = util.truncate_path(b'abcde/fgh', 4)
     self.assertEqual(p, b'abcd/fgh')
Example #19
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'))
Example #20
0
 def test_truncate_unicode(self):
     with _common.platform_posix():
         p = util.truncate_path(u'abcde/fgh', 4)
     self.assertEqual(p, u'abcd/fgh')
Example #21
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')
Example #22
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')
Example #23
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'')
Example #24
0
 def test_sanitize_unix_replaces_leading_dot(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'one/.two/three')
     self.assertFalse(u'.' in p)
Example #25
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, b'/base/' + dest)
Example #26
0
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
Example #27
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'))
Example #28
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(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'a/.?/b')
Example #29
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')
Example #30
0
 def test_sanitize_with_custom_replace_adds_replacements(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo/bar', [
             (re.compile(r'foo'), u'bar'),
         ])
     self.assertEqual(p, u'bar/bar')
Example #31
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'')
Example #32
0
 def test_sanitize_empty_component(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'foo//bar', [
             (re.compile(r'^$'), u'_'),
         ])
     self.assertEqual(p, u'foo/_/bar')
Example #33
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, '/base/' + dest)
Example #34
0
 def test_syspath_posix_unchanged(self):
     with _common.platform_posix():
         path = os.path.join(u'a', u'b', u'c')
         outpath = util.syspath(path)
     self.assertEqual(path, outpath)