Exemple #1
0
    def test_goodfile(self):
        # Our file templates.  Try a vanilla version and one with escapes.
        # NB:
        # This is only supported on the Mac at the moment, when 
        # windows support arrives we will need to extract the paths and
        # see what it looks like and add a test here.
        path1 = "/Users/xxx/Music/iTunes/iTunes%20Music/"
        path2 = ("/Volumes/%E3%83%9B%E3%83%BC%E3%83%A0/" +
                 "xxx/Music/iTunes/iTunes%20Media/")
        file_snippet1 = file_template % dict(path=(self.file_url + path1))
        file_snippet2 = file_template % dict(path=(self.file_url + path2))

        tmpf_dir = os.path.dirname(self.tmpf_path)
        # Test vanilla path
        self._clean_tmpf()
        self.tmpf.write(file_snippet1)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(path, urllib.url2pathname(path1))

        # Test path with utf-8 escapes
        self._clean_tmpf()
        self.tmpf.write(file_snippet2)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(path, urllib.url2pathname(path2))
Exemple #2
0
    def test_badfile(self):
        self._clean_tmpf()

        # write some junk to the file and see what happens.
        self.tmpf.write('JUNKJUNKJUNKJUNKJUNK')
        self.tmpf.flush()

        tmpf_dir = os.path.dirname(self.tmpf_path)
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(path, None)
Exemple #3
0
    def test_badfile(self):
        self._clean_tmpf()
        path1 = "/Users/xxx/Music/iTunes/iTunes Music/"
        file_snippet1 = file_template % dict(path=(self.file_url + path1))

        # write some junk to the file and see what happens.
        self.tmpf.write('JUNKJUNKJUNKJUNKJUNK')
        self.tmpf.flush()

        tmpf_dir = os.path.dirname(self.tmpf_path)
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(path, None)
Exemple #4
0
def get_plat_media_player_name_path():
    music_path = specialfolders.get_special_folder("My Music")
    if music_path == None:
        # if specialfolders returns None, then My Music doesn't exist
        # so we return (None, None) indicating there's no media
        # player.

        # FIXME - can the iTunes folder be in another place?
        return (None, None)

    itunes_path = os.path.join(music_path, 'iTunes')
    return (_('iTunes'), import_itunes_path(itunes_path))
Exemple #5
0
def get_plat_media_player_name_path():
    music_path = specialfolders.get_special_folder("My Music")
    if music_path == None:
        # if specialfolders returns None, then My Music doesn't exist
        # so we return (None, None) indicating there's no media
        # player.

        # FIXME - can the iTunes folder be in another place?
        return (None, None)

    itunes_path = os.path.join(music_path, 'iTunes')
    return (_('iTunes'), import_itunes_path(itunes_path))
Exemple #6
0
    def test_goodfile(self):
        # Our file templates.  Try a vanilla version and one with escapes,
        # and a path for Windows.
        path1 = "/Users/xxx/Music/iTunes/iTunes%20Music/"
        path2 = ("/Volumes/%E3%83%9B%E3%83%BC%E3%83%A0/"
                 "xxx/Music/iTunes/iTunes%20Media/")
        path3 = ("C:/Documents%20and%20Settings/Paul/"
                 "My%20Documents/My%20Music/iTunes/iTunes%20Media/")
        file_snippet1 = file_template % dict(path=(self.file_url + path1))
        file_snippet2 = file_template % dict(path=(self.file_url + path2))
        file_snippet3 = file_template % dict(path=(self.file_url + path3))

        tmpf_dir = os.path.dirname(self.tmpf_path)
        # Test vanilla path
        self._clean_tmpf()
        self.tmpf.write(file_snippet1)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(type(path), unicode)
        self.assertEquals(path, filename_to_unicode(
                urllib.url2pathname(path1)))

        # Test path with utf-8 escapes
        self._clean_tmpf()
        self.tmpf.write(file_snippet2)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(type(path), unicode)
        self.assertEquals(path, filename_to_unicode(
                urllib.url2pathname(path2)))

        # Test Windows path
        self._clean_tmpf()
        self.tmpf.write(file_snippet3)
        self.tmpf.flush()
        path = import_itunes_path(tmpf_dir)
        self.assertEquals(type(path), unicode)
        self.assertEquals(path, filename_to_unicode(
                urllib.url2pathname(path3)))
Exemple #7
0
 def test_nofile(self):
     path = import_itunes_path("/non/existtent/path")
     self.assertEquals(path, None)
Exemple #8
0
def get_plat_media_player_name_path():
    itunespath = os.path.join(os.path.expanduser("~"), "Music", "iTunes")
    return (_("iTunes"), import_itunes_path(itunespath))
Exemple #9
0
 def test_nofile(self):
     path = import_itunes_path("/non/existtent/path")
     self.assertEquals(path, None)
Exemple #10
0
def get_plat_media_player_name_path():
    itunespath = os.path.join(os.path.expanduser("~"), "Music", "iTunes")
    return (_("iTunes"), import_itunes_path(itunespath))