Пример #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'))
Пример #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)
Пример #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')
Пример #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'))
Пример #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)
Пример #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)
Пример #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')
Пример #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')
Пример #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')
Пример #10
0
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
Пример #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')
Пример #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)
Пример #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')
Пример #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')
Пример #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)
Пример #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)
Пример #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')
Пример #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')
Пример #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'))
Пример #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')
Пример #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')
Пример #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')
Пример #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'')
Пример #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)
Пример #25
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, b'/base/' + dest)
Пример #26
0
 def test_sanitize_path_works_on_empty_string(self):
     with _common.platform_posix():
         p = util.sanitize_path(u'')
     self.assertEqual(p, u'')
Пример #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'))
Пример #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')
Пример #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')
Пример #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')
Пример #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'')
Пример #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')
Пример #33
0
 def _assert_dest(self, dest):
     with _common.platform_posix():
         the_dest = self.i.destination()
     self.assertEqual(the_dest, '/base/' + dest)
Пример #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)