Exemplo n.º 1
0
 def Add(self, file_name):
     f = mp3_file.Mp3File(file_name)
     hash = self.hasher(f.data()).digest()
     if hash in self.file_dict:
         self.duplicateFileHandler(file_name)
     else:
         self.file_dict[hash] = file_name
Exemplo n.º 2
0
 def test_data_no_id3(self):
     file = io.BytesIO(MP3_FILE_NO_ID3)
     mp3 = mp3_file.Mp3File(file)
     self.assertEqual(MP3_FILE_NO_ID3, mp3.data())
Exemplo n.º 3
0
 def test_data_id3_header_and_trailer(self):
     file = io.BytesIO(MP3_FILE_ID3_HEADER_AND_TRAILER)
     mp3 = mp3_file.Mp3File(file)
     self.assertEqual(MP3_FILE_NO_ID3, mp3.data())
Exemplo n.º 4
0
 def test_data_too_short(self):
     file = io.BytesIO(MP3_FILE_TOO_SHORT)
     mp3 = mp3_file.Mp3File(file)
     self.assertEqual(MP3_FILE_TOO_SHORT, mp3.data())
Exemplo n.º 5
0
 def test_data_empty(self):
     file = io.BytesIO(MP3_FILE_EMPTY)
     mp3 = mp3_file.Mp3File(file)
     self.assertEqual(MP3_FILE_EMPTY, mp3.data())
Exemplo n.º 6
0
    def test_reading_file_with_short_data_returns_mp3_data(self):
        mp3 = mp3_file.Mp3File("myMp3File")

        self.assertEqual(SHORT_DATA, mp3.data())
Exemplo n.º 7
0
    def test_reading_file_with_header_and_trailer_returns_mp3_data(self):
        mp3 = mp3_file.Mp3File("myMp3File")

        self.assertEqual(MP3_DATA, mp3.data())
Exemplo n.º 8
0
 def Hash(self, name):
     with io.open(name, 'rb') as f:
         mp3 = mp3_file.Mp3File(f)
         return self.hasher(mp3.data())