Example #1
0
 def test_effective_size(self):
     with database.Database(database_override='./tests/database/com.plexapp.plugins.library.db') as db:
         library = Library(db)
         movie = Movie(2, u"a", 'b', 1, 2, 2.2, 'd', 1, 'e', '/test')
         movie.exist = False
         library._update_library(movie)
         self.assertEqual(library.effective_size, self._effective_size)
         movie.exist = True
         movie.matched = True
         library._update_library(movie)
         self.assertEqual(library.effective_size, self._effective_size + 2)
Example #2
0
    def test_init(self):
        movie = Movie(
            1, u"Burn Notice: The Fall of Sam Axe",
            os.path.join(self._lib, 'Burn Notice The Fall of Sam Axe.avi'),
            2010, 2, 2.2, 'local://1', 1, 'thumb1', '/test/media/library')
        self.assertFalse(movie.matched)

        movie = Movie(
            2, u"Burn Notice: The Fall of Sam Axe",
            os.path.join(self._lib, "Burn Notice The Fall of Sam Axe.avi"),
            2010, 2, 2.2, "someGUID", 1, self._jacket, '/test/media/library')
        self.assertTrue(movie.matched)
Example #3
0
 def test_get_metadata_jacket(self):
     movie = Movie(4, u"a", 'b', 2010, 2, 2.2, 'c', 1, self._jacket,
                   '/test/media/library')
     movie.matched = False
     self.assertIsNone(movie.get_metadata_jacket())
     movie.matched = True
     self.assertIsNotNone(movie.get_metadata_jacket())
     h = hashlib.sha1('c').hexdigest()
     self.assertTrue(h[1:] in movie.get_metadata_jacket())
Example #4
0
 def test_get_metadata_jacket(self):
     movie = Movie(4, u"a", 'b', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     movie.matched = False
     self.assertIsNone(movie.get_metadata_jacket())
     movie.matched = True
     self.assertIsNotNone(movie.get_metadata_jacket())
     h = hashlib.sha1('c').hexdigest()
     self.assertTrue(h[1:] in movie.get_metadata_jacket())
Example #5
0
 def test_update_database(self):
     with Database(database_override=
                   './tests/database/com.plexapp.plugins.library.db') as db:
         m = Movie(
             1, u"a", '/tests/b.avi', 2010, 2, 2.2, 'c', 1,
             './tests/posters/com.plexapp.agents.themoviedb_1a3b1b98c2799d759e110285001f536982cdb869',
             '/test')
         before = db._cursor.execute(
             'SELECT file FROM media_parts WHERE id = ?',
             (m.mid, )).fetchone()
         cleaner.update_database(db, m)
         after = db._cursor.execute(
             'SELECT file FROM media_parts WHERE id = ?',
             (m.mid, )).fetchone()
         self.assertNotEqual(before[0], after[0])
         db.rollback()
Example #6
0
 def test_str(self):
     movie = Movie(6, u"a", '/tests/b.avi', 2010, 2, 2.2, 'c', 1,
                   self._jacket, '/test/media/library')
     json_dict = json.loads(str(movie))
     self.assertTrue('fps' in json_dict)
     self.assertTrue('size' in json_dict)
     self.assertTrue('filepath' in json_dict)
     self.assertTrue('title' in json_dict)
     self.assertTrue('correct_title' in json_dict)
     self.assertTrue('title_distance' in json_dict)
     self.assertTrue('year' in json_dict)
     self.assertTrue('matched' in json_dict)
     self.assertTrue('exist' in json_dict)
     self.assertTrue('filename' in json_dict)
     self.assertTrue('relative_jacket_path' in json_dict)
     self.assertTrue('original_file' in json_dict)
     self.assertTrue('mid' in json_dict)
     self.assertTrue('need_update' in json_dict)
Example #7
0
 def test_clean_filename(self):
     movie = Movie(3, u"abc-:;&%#@def", '123', 2010, 2, 2.2, 'someGUID', 1,
                   'thumb1', '/test/media/library')
     self.assertEqual(movie._clean_filename(), 'abc-anddef')
Example #8
0
 def test_need_update_true(self):
     movie = Movie(4, u"a", '/tests/b.avi', 2010, 2, 2.2, 'c', 1,
                   self._jacket, '/test/media/library')
     self.assertTrue(movie.need_update())
Example #9
0
 def test_get_correct_absolute_path_similar(self):
     movie = Movie(4, u"a", '/tests/a (2010)/b.avi', 2010, 2, 2.2, 'c', 1,
                   self._jacket, '/test/media/library')
     self.assertEqual(movie.get_correct_absolute_path(), "/tests/a (2010)")
Example #10
0
 def test_get_correct_directory(self):
     movie = Movie(1, u"a", 'b.avi', 2010, 2, 2.2, 'c', 1, self._jacket,
                   '/test/media/library')
     self.assertEqual(movie.get_correct_directory(), "a (2010)")
Example #11
0
 def test_get_correct_absolute_path_similar(self):
     movie = Movie(4, u"a", '/tests/a (2010)/b.avi', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     self.assertEqual(movie.get_correct_absolute_path(), "/tests/a (2010)")
Example #12
0
 def test_get_correct_path(self):
     movie = Movie(3, u"a", 'b.avi', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     self.assertEqual(movie.get_correct_path(), "a (2010)/a (2010).avi")
Example #13
0
 def test_get_correct_directory(self):
     movie = Movie(1, u"a", 'b.avi', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     self.assertEqual(movie.get_correct_directory(), "a (2010)")
Example #14
0
 def test_get_metadata_jacket_parsing(self):
     movie = Movie(1, u"a", 'b.avi', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     self.assertEqual(14, len(movie.get_metadata_jacket().split('/')))
Example #15
0
 def test_clean_filename(self):
     movie = Movie(3, u"abc-:;&%#@def", '123', 2010, 2, 2.2, 'someGUID', 1, 'thumb1', '/test/media/library')
     self.assertEqual(movie._clean_filename(), 'abc-anddef')
Example #16
0
 def test_get_metadata_jacket_parsing(self):
     movie = Movie(1, u"a", 'b.avi', 2010, 2, 2.2, 'c', 1, self._jacket,
                   '/test/media/library')
     self.assertEqual(14, len(movie.get_metadata_jacket().split('/')))
Example #17
0
 def test_get_correct_absolute_path_with_override(self):
     movie = Movie(5, u"a", '/tests/b.avi', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     self.assertEqual(movie.get_correct_absolute_path(override='/temp'), "/temp/a (2010)")
Example #18
0
 def test_get_correct_path(self):
     movie = Movie(3, u"a", 'b.avi', 2010, 2, 2.2, 'c', 1, self._jacket,
                   '/test/media/library')
     self.assertEqual(movie.get_correct_path(), "a (2010)/a (2010).avi")
Example #19
0
 def test_need_update_true(self):
     movie = Movie(4, u"a", '/tests/b.avi', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     self.assertTrue(movie.need_update())
Example #20
0
 def test_get_correct_absolute_path_with_override(self):
     movie = Movie(5, u"a", '/tests/b.avi', 2010, 2, 2.2, 'c', 1,
                   self._jacket, '/test/media/library')
     self.assertEqual(movie.get_correct_absolute_path(override='/temp'),
                      "/temp/a (2010)")
Example #21
0
 def test_should_update_false(self):
     movie = Movie(4, u"a", '/tests/a (2010)/a (2010).avi', 2010, 2, 2.2, 'c', 1, self._jacket, '/test/media/library')
     self.assertFalse(movie.need_update())
Example #22
0
 def test_should_update_false(self):
     movie = Movie(4, u"a", '/tests/a (2010)/a (2010).avi', 2010, 2, 2.2,
                   'c', 1, self._jacket, '/test/media/library')
     self.assertFalse(movie.need_update())
Example #23
0
 def test_update_library(self):
     with database.Database(database_override='./tests/database/com.plexapp.plugins.library.db') as db:
         library = Library(db)
         movie = Movie(1, u"a", 'b', 1, 2, 2.2, 'd', 1, 'e', '/test')
         library._update_library(movie)
         self.assertEqual(len(library), self._nb_movie + 1)