Пример #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)
Пример #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)
Пример #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())
Пример #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())
Пример #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()
Пример #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)
Пример #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')
Пример #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())
Пример #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)")
Пример #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)")
Пример #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)")
Пример #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")
Пример #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)")
Пример #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('/')))
Пример #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')
Пример #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('/')))
Пример #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)")
Пример #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")
Пример #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())
Пример #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)")
Пример #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())
Пример #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())
Пример #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)