How to use trakt - 10 common examples

To help you get started, we’ve selected a few trakt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fuzeman / trakt.py / tests / sync / playback / test_delete.py View on Github external
def test_basic():
    with HTTMock(mock.sync_get, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            collection = Trakt['sync/playback'].get()

    # Ensure collection is valid
    assert_that(collection, not_none())
    
    # Batman Begins (2005)
    assert_that(collection[('imdb', 'tt0372784')], has_properties({
        'id': 13
    }))
    
    # Breaking Bad (2008)
    assert_that(collection[('tvdb', '81189')], has_properties({
        # Seasons
        'seasons': all_of(
            has_length(1),
github fuzeman / trakt.py / tests / sync / history / test_shows.py View on Github external
def test_basic():
    with HTTMock(mock.fixtures, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            history = Trakt['sync/history'].shows(pagination=True, per_page=5)

    # Ensure collection is valid
    assert_that(history, not_none())

    # Resolve all pages
    items = list(history)

    # Ensure all items have been returned
    assert_that(items, has_length(25))

    # Verify item identifiers
    assert_that(
        [item.id for item in items],
        equal_to(list(xrange(1, 26)))
    )
github fuzeman / trakt.py / tests / test_http.py View on Github external
ev = Event()

    @httmock.all_requests
    def handler(url, request):
        if ev.is_set():
            return httmock.response(201, request=request)

        # Set event
        ev.set()

        # Raise error
        raise ConnectionError('Example')

    with HTTMock(handler):
        with pytest.raises(ConnectionError):
            Trakt.http.get('/test')
github fuzeman / trakt.py / tests / test_progress.py View on Github external
def test_progress_collection():
    with HTTMock(mock.fixtures, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            progress = Trakt['shows'].progress_collection(1390)

    assert progress is not None
    assert progress.reset_at is None
    assert progress.last_progress_change is not None

    assert progress.seasons[1].episodes[1].progress_timestamp is not None

    # Next Episode
    assert progress.next_episode is not None
    assert progress.next_episode.pk == (1, 7)

    assert progress.next_episode.keys == [
        (1, 7),

        ('tvdb', '3436461'),
        ('tmdb', '63062'),
github fuzeman / trakt.py / tests / test_calendars.py View on Github external
def test_my_dvd():
    with HTTMock(mock.calendars_my, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            items = Trakt['calendars/my/dvd'].get()

    # Ensure request was successful
    assert_that(items, not_none())
    assert_that(items, has_length(3))

    # Guardians of the Galaxy (2014)
    assert_that(items[0], has_properties({
        'pk': ('imdb', 'tt2015381'),
        'title': u'Guardians of the Galaxy',
        'year': 2014,

        'released': date(2014, 8, 1)
    }))

    # Get On Up (2014)
github fuzeman / trakt.py / tests / test_sync_shows.py View on Github external
def test_playback():
    responses.add_callback(
        responses.GET, 'http://mock/sync/playback/episodes',
        callback=authenticated_response('fixtures/sync/playback/episodes.json'),
        content_type='application/json'
    )

    Trakt.base_url = 'http://mock'

    with Trakt.configuration.auth('mock', 'mock'):
        playback = Trakt['sync/playback'].episodes()

    assert playback is not None

    # Validate `Show`
    show = playback[('tvdb', '80348')]

    assert show.title == 'Chuck'
    assert show.year == 2007

    assert len(show.seasons) == 1

    # Validate `Season`
    season = show.seasons[1]

    assert season.show == show
github fuzeman / trakt.py / tests / users / lists / test_create.py View on Github external
def test_create():
    with HTTMock(mock.list_create, mock.fixtures):
        with Trakt.configuration.auth('mock', 'mock'):
            movies = Trakt['users/me/lists'].create(name='Movies')

    # Validate movies list
    assert movies is not None

    assert movies.name == 'Movies'
    assert movies.description is None
    assert movies.likes == 0

    assert movies.allow_comments is True
    assert movies.display_numbers is False

    assert movies.updated_at == datetime(2015, 6, 22, 2, 25, tzinfo=tzutc())

    assert movies.comment_count == 0
    assert movies.item_count == 2
github fuzeman / trakt.py / tests / sync / history / test_mixed.py View on Github external
def test_basic():
    with HTTMock(mock.fixtures, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            history = Trakt['sync/history'].get(pagination=True, per_page=5)

    # Ensure collection is valid
    assert_that(history, not_none())

    # Resolve all pages
    items = list(history)

    # Ensure all items have been returned
    assert_that(items, has_length(3))

    # Verify item identifiers
    assert_that(
        [item.id for item in items],
        equal_to(list(xrange(1, 4)))
    )
github fuzeman / trakt.py / tests / sync / watched / test_shows.py View on Github external
def test_watched():
    with HTTMock(mock.fixtures, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            collection = Trakt['sync/watched'].shows()

    # Ensure collection is valid
    assert_that(collection, not_none())
    assert_that(collection, has_length(9))

    # Chuck (2007)
    assert_that(collection[('tvdb', '80348')], has_properties({
        'pk': ('tvdb', '80348'),
        'title': 'Chuck',
        'year': 2007,

        # Seasons
        'seasons': all_of(
            has_length(1),
            has_entry(1, has_properties({
github fuzeman / trakt.py / tests / test_sync_shows.py View on Github external
def test_collection():
    responses.add_callback(
        responses.GET, 'http://mock/sync/collection/shows',
        callback=authenticated_response('fixtures/sync/collection/shows.json'),
        content_type='application/json'
    )

    Trakt.base_url = 'http://mock'

    with Trakt.configuration.auth('mock', 'mock'):
        collection = Trakt['sync/collection'].shows()

    assert collection is not None
    assert len(collection) == 4

    # Validate `Show`
    show = collection[('tvdb', '80348')]

    assert show.title == 'Chuck'
    assert show.year == 2007

    assert show.pk == ('tvdb', '80348')
    assert show.keys == [
        ('tvdb', '80348'),
        ('tmdb', '1404'),
        ('imdb', 'tt0934814'),