def test_proper_episode_replaces_old(self): # moving media flle proper_file_source_path = self.__TV_SHOW_2_FILE_PROPER proper_file_destination_path = self._SHOW_DESTINATION_DIRECTORY + 'Mordeaa/Season 6/' + self.__TV_SHOW_2_FILE_PROPER # moving random file with same file name proper_file_source_path_nfo = self.__TV_SHOW_2_FILE_PROPER_NFO proper_file_destination_path_nfo = self._SHOW_DESTINATION_DIRECTORY + 'Mordeaa/Season 6/' + self.__TV_SHOW_2_FILE_PROPER_NFO self.__assert_tv_shows_files( [proper_file_source_path, proper_file_source_path_nfo], [proper_file_destination_path, proper_file_destination_path_nfo]) # original 1 should not exist anymore original_1_path = self._SHOW_DESTINATION_DIRECTORY + 'Mordeaa/Season 6/' + self.__TV_SHOW_2_FILE_ORIGINAL_1 self.assertFalse(file_handler.file_exist(original_1_path)) original_1_path = self._SHOW_DESTINATION_DIRECTORY + 'Mordeaa/Season 6/' + self.__TV_SHOW_2_FILE_ORIGINAL_1_NFO self.assertFalse(file_handler.file_exist(original_1_path)) # original 2 should still exist original_2_path = self._SHOW_DESTINATION_DIRECTORY + 'Mordeaa/Season 6/' + self.__TV_SHOW_2_FILE_3_ORIGINAL_2 self.assertTrue(file_handler.file_exist(original_2_path)) original_2_path = self._SHOW_DESTINATION_DIRECTORY + 'Mordeaa/Season 6/' + self.__TV_SHOW_2_FILE_ORIGINAL_2_NFO self.assertTrue(file_handler.file_exist(original_2_path))
def test_moving_multiple_files(self): def run_app(): args = f'{self._SOURCE_DIRECTORY} {self._SHOW_DESTINATION_DIRECTORY} {self._MOVIE_DESTINATION_DIRECTORY} --moves 2' execution = f'{sys.executable} -m memover watch {args}' p = subprocess.Popen(execution, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return p process = run_app() time.sleep(1) self._createSourceFile(self.__test_file_1) self._createSourceFile(self.__test_file_2) for line in process.stdout.readlines(): print(line) process.wait() file_is_in_new_path = file_handler.file_exist( self.__get_destination_path_file_1()) self.assertTrue(file_is_in_new_path) file_is_in_new_path = file_handler.file_exist( self.__get_destination_path_file_2()) self.assertTrue(file_is_in_new_path)
def test_renaming_subs(self): source_files = [ 'a_movie_with_subs/Another.Another.S02E03.bigfile.mp4', 'a_movie_with_subs/intetest/Other.Other.Other.Other.S09E01.something.something-something[something].swe.srt', 'a_movie_with_subs/Other.Other.Other.Other.S09E01.something.something-something[something].smi', 'a_movie_with_subs/[ www.flobbing.com ] - /Other.Other.Other.Other.S09E01.something.something-something[something].ssa', 'a_movie_with_subs/[ www.flobbing.com ] - Longer.S01E02.HaHV.Maam-A/Information Downloaded From www.akkero.com.ass', 'a_movie_with_subs/a/b/www.Lobertar.com - Long.S01E02.720p.KOOK.asdf-Risig/Stuff from www.Lobertar.com.vtt', 'a_movie_with_subs/www.Lobertar.com - Long.S01E02.720p.KOOK.asdf-Risig/Stuff from www.Lobertar.com.txt', 'a_movie_with_subs/intetest/Other.Other.Other.Other.S09E01.something.something-something[something].eng.srt' ] subtitles_file = [ 'a_movie_with_subs/Another.Another.S02E03.bigfile.en3.smi', 'a_movie_with_subs/Another.Another.S02E03.bigfile.en.ass', 'a_movie_with_subs/Another.Another.S02E03.bigfile.en5.vtt', 'a_movie_with_subs/Another.Another.S02E03.bigfile.en4.ssa', 'a_movie_with_subs/Another.Another.S02E03.bigfile.en2.srt', 'a_movie_with_subs/Another.Another.S02E03.bigfile.sv.srt', ] # Create source files for source_file in source_files: self._createSourceFile(source_file) # make the first file the biggest self._set_size_in_mb(source_files[0], 60) subtitles.rename_and_move(self._SOURCE_DIRECTORY) for path in subtitles_file: self.assertTrue(file_handler.file_exist(self._SOURCE_DIRECTORY + path)) # assert that none sub files have not changed self.assertTrue(file_handler.file_exist(self._SOURCE_DIRECTORY + source_files[0])) self.assertFalse( file_handler.directory_exist(file_handler.get_parent(self._SOURCE_DIRECTORY + source_files[1])) ) self.assertFalse( file_handler.file_exist(self._SOURCE_DIRECTORY + source_files[2]) ) self.assertFalse( file_handler.directory_exist(file_handler.get_parent(self._SOURCE_DIRECTORY + source_files[3])) ) self.assertFalse( file_handler.file_exist(file_handler.get_parent(self._SOURCE_DIRECTORY + source_files[4])) ) self.assertFalse( file_handler.directory_exist('testing/1') ) self.assertTrue(file_handler.file_exist(self._SOURCE_DIRECTORY + source_files[6]))
def _assert_file_moved(self, source_path, destination_path): file_is_in_new_path = file_handler.file_exist(destination_path) if not file_is_in_new_path: raise AssertionError('file does not exist in new path: ' + source_path) edited_source_path = source_path if self._SOURCE_DIRECTORY not in edited_source_path: edited_source_path = self._SOURCE_DIRECTORY + source_path file_is_in_old_path = file_handler.file_exist(edited_source_path) if file_is_in_old_path: raise AssertionError('file is still in old path')
def test_move_show_by_name(self): tv_show_file_name = 'All.the.Things.Fire.S02E10.720p.SOMETHING.something-SOMETHING.mkv' file_handler.create_file(self._SOURCE_DIRECTORY + tv_show_file_name) mover.move_media_by_name('all the things fire', self._SOURCE_DIRECTORY, self._SHOW_DESTINATION_DIRECTORY, self._MOVIE_DESTINATION_DIRECTORY) destination_path = self._SHOW_DESTINATION_DIRECTORY + '/All the Things Fire/Season 2/' + tv_show_file_name file_is_in_new_path = file_handler.file_exist(destination_path) self.assertTrue(file_is_in_new_path) source_path = self._SOURCE_DIRECTORY + '/' + tv_show_file_name file_is_in_old_path = file_handler.file_exist(source_path) self.assertFalse(file_is_in_old_path)
def test_that_proper_replace_old_episode(self): self.__run_by_file( 'sourcefolder/Old.Stuff.S02E15.PROPER.720p.HDTV.x264-KILLERS[rarbg].cold' ) proper_file_destination_path = self._SHOW_DESTINATION_DIRECTORY + 'Old Stuff/Season 2/' + self.__TV_SHOW_FILE_NAME_3_PROPER wrong_file_destination_path = self._SHOW_DESTINATION_DIRECTORY + 'Old Stuff/Season 2/' + self.__TV_SHOW_FILE_NAME_3_ORIGINAL self.assertFalse(file_handler.file_exist(wrong_file_destination_path)) self._assert_file_moved( self._SOURCE_DIRECTORY + self.__TV_SHOW_FILE_NAME_3_PROPER, proper_file_destination_path)