from __future__ import unicode_literals, division, absolute_import
from builtins import *  # pylint: disable=unused-import, redefined-builtin

import pytest

from flexget.plugins.list.imdb_list import ImdbEntrySet


@pytest.mark.online
class TestIMDBListTypes(object):
    imdb_config = {'login': '<EMAIL>',
                   'password': '<PASSWORD>',
                   'list': 'watchlist'}

    config = """
        tasks:
          imdb_list_add:
            mock:
              - {title: 'the matrix', url: 'http://localhost/seen1', imdb_id: 'tt0133093'}
              - {title: 'black mirror', url: 'http://localhost/seen2', imdb_id: 'tt2085059'}
            accept_all: yes
            list_add:
              - imdb_list:
                  login: '<EMAIL>'
                  password: '<PASSWORD>'
                  list: 'watchlist'

          imdb_list_get:
            imdb_list:
              login: '<EMAIL>'
              password: '<PASSWORD>'
              list: 'watchlist'
            accept_all: yes

          imdb_list_remove:
            imdb_list:
              login: '<EMAIL>'
              password: '<PASSWORD>'
              list: 'watchlist'
            accept_all: yes
            list_remove:
              - imdb_list:
                  login: '<EMAIL>'
                  password: '<PASSWORD>'
                  list: 'watchlist'
    """

    def test_imdb_list(self, execute_task):
        imdb_set = ImdbEntrySet(self.imdb_config)
        # Clearing existing list
        imdb_set.clear()

        task = execute_task('imdb_list_add')
        assert len(task.accepted) == 2

        task = execute_task('imdb_list_get')
        assert len(task.accepted) == 2
        assert task.find_entry(movie_name='The Matrix', movie_year=1999)
        assert task.find_entry(series_name='Black Mirror', series_year=2011)

        task = execute_task('imdb_list_remove')
        assert len(task.all_entries) == 2

        task = execute_task('imdb_list_get')
        assert len(task.accepted) == 0

from __future__ import unicode_literals, division, absolute_import
from builtins import *  # pylint: disable=unused-import, redefined-builtin

import pytest

from flexget.plugins.list.imdb_list import ImdbEntrySet


@pytest.mark.online
class TestIMDBListTypes(object):
    imdb_config = {'login': '<EMAIL>',
                   'password': '<PASSWORD>',
                   'list': 'watchlist'}

    config = """
        tasks:
          imdb_list_add:
            mock:
              - {title: 'the matrix', url: 'http://localhost/seen1', imdb_id: 'tt0133093'}
              - {title: 'black mirror', url: 'http://localhost/seen2', imdb_id: 'tt2085059'}
            accept_all: yes
            list_add:
              - imdb_list:
                  login: '<EMAIL>'
                  password: '<PASSWORD>'
                  list: 'watchlist'

          imdb_list_get:
            imdb_list:
              login: '<EMAIL>'
              password: '<PASSWORD>'
              list: 'watchlist'
            accept_all: yes

          imdb_list_remove:
            imdb_list:
              login: '<EMAIL>'
              password: '<PASSWORD>'
              list: 'watchlist'
            accept_all: yes
            list_remove:
              - imdb_list:
                  login: '<EMAIL>'
                  password: '<PASSWORD>'
                  list: 'watchlist'
    """

    def test_imdb_list(self, execute_task):
        imdb_set = ImdbEntrySet(self.imdb_config)
        # Clearing existing list
        imdb_set.clear()

        task = execute_task('imdb_list_add')
        assert len(task.accepted) == 2

        task = execute_task('imdb_list_get')
        assert len(task.accepted) == 2
        assert task.find_entry(movie_name='The Matrix', movie_year=1999)
        assert task.find_entry(series_name='Black Mirror', series_year=2011)

        task = execute_task('imdb_list_remove')
        assert len(task.all_entries) == 2

        task = execute_task('imdb_list_get')
        assert len(task.accepted) == 0

# pylint: disable=unused-import, redefined-builtin tasks:           imdb_list_add:             mock:               - {title: 'the matrix', url: 'http://localhost/seen1', imdb_id: 'tt0133093'}               - {title: 'black mirror', url: 'http://localhost/seen2', imdb_id: 'tt2085059'}             accept_all: yes             list_add:               - imdb_list:                   login: '<EMAIL>'                   password: '<PASSWORD>'                   list: 'watchlist'            imdb_list_get:             imdb_list:               login: '<EMAIL>'               password: '<PASSWORD>'               list: 'watchlist'             accept_all: yes            imdb_list_remove:             imdb_list:               login: '<EMAIL>'               password: '<PASSWORD>'               list: 'watchlist'             accept_all: yes             list_remove:               - imdb_list:                   login: '<EMAIL>'                   password: '<PASSWORD>'                   list: 'watchlist' # Clearing existing list