Exemplo n.º 1
0
 def test_can_add_filename_to_movie_data_when_movie_found(self):
     moviedb2.load_movie_data( self.movie_data_path )
     self.make_file(self.new_file)
     hash = moviedb2.get_1mb_checksum (self.new_file)
     moviedb2.add_new_movie( self.new_file, hash  )
     assert not moviedb2.is_new_movie( hash )
     assert not moviedb2.is_movie_sent( hash )
Exemplo n.º 2
0
 def add_file_to_data_file(self, filename):
     try:
         with open(self.movie_data_path, 'r') as f:
             data = json.load(f)
     except:
         data = {}
     data[moviedb2.get_1mb_checksum(filename)]= {"filename": filename, "status":"found"}
     with open(self.movie_data_path, 'w') as f:
         json.dump(data, f)
Exemplo n.º 3
0
 def test_can_write_movie_data_to_file(self):
     moviedb2.load_movie_data( self.movie_data_path )
     self.make_file(self.new_file)
     hash = moviedb2.get_1mb_checksum (self.new_file)
     moviedb2.add_new_movie( self.new_file, hash  )
     moviedb2.set_movie_sent( hash )
     moviedb2.write_movie_data( self.tmp_movie_data_path ) # this is being tested
     moviedb2.load_movie_data( self.tmp_movie_data_path )
     assert not moviedb2.is_new_movie( hash )
     assert moviedb2.is_movie_sent( hash )
Exemplo n.º 4
0
 def setUp(self):
     self.test_folder = os.path.join("tests", "data" "test_movies")
     self.movie_data_path = os.path.join("tests", "data", "test-movie-data.json")
     self.tmp_movie_data_path = os.path.join("tests", "data", "test-movie-data-modified.json")
     self.new_file = os.path.join(self.test_folder,"filename4.avi")
     moviedb2.load_config ( "config.yml" )
     self.files = [ {"filename": os.path.join(self.test_folder, "test1 {tt1234567}.avi")},
                    {"filename": os.path.join(self.test_folder, "A", "test2 {tt2345678}.mp4")},
                    {"filename": os.path.join(self.test_folder, "B", "test3.mkv")}]
     os.mkdir(self.test_folder)
     os.mkdir(os.path.join(self.test_folder, "A"))
     os.mkdir(os.path.join(self.test_folder, "B"))
     for f in self.files:
         self.make_file(f["filename"])
         self.add_file_to_data_file(f["filename"])
         f["hash"] = moviedb2.get_1mb_checksum(f["filename"])
Exemplo n.º 5
0
 def test_can_check_movie_data_to_see_if_movie_found(self):
     moviedb2.load_movie_data( self.movie_data_path )
     self.make_file(self.new_file)
     assert moviedb2.is_new_movie( moviedb2.get_1mb_checksum(self.new_file))
     assert not moviedb2.is_new_movie( self.files[0]["hash"] )
Exemplo n.º 6
0
 def test_get_checksum_1mb_returns_checksum(self):
     checksum_file = os.path.join('tests','data','checksum-test.avi')
     expected_checksum = "3e9c3a8b73eab486bda7330cff4e0195" # calced using md5sum program in Ubuntu
     assert_equals( moviedb2.get_1mb_checksum(checksum_file), expected_checksum )