from collections import defaultdict
from bite_030 import (get_movies_by_director, get_average_scores,
                       calc_mean_score, Movie)

director_movies = get_movies_by_director()


def test_get_movies_by_director():
    assert '<NAME>' in director_movies
    assert len(director_movies['<NAME>']) == 4
    assert len(director_movies['<NAME>']) == 12


def test_director_movies_data_structure():
    assert type(director_movies) in (dict, defaultdict)
    assert type(director_movies['<NAME>']) == list
    assert type(director_movies['<NAME>'][0]) == Movie


def test_calc_mean_score():
    movies_sergio = director_movies['<NAME>']
    movies_nolan = director_movies['<NAME>']
    assert calc_mean_score(movies_sergio) == 8.5
    assert calc_mean_score(movies_nolan) == 8.4


def test_get_average_scores():
    avg_scores = get_average_scores(director_movies)[:10]
    expected = [('<NAME>', 8.5),
                ('<NAME>', 8.4),
                ('<NAME>', 8.2),
                ('<NAME>', 8.2),
                ('<NAME>', 8.0),
                ('<NAME>', 8.0),
                ('<NAME>', 7.9),
                ('<NAME>', 7.9),
                ('<NAME>', 7.8),
                ('<NAME>', 7.8)]
    assert avg_scores == expected

from collections import defaultdict
from bite_030 import (get_movies_by_director, get_average_scores,
                       calc_mean_score, Movie)

director_movies = get_movies_by_director()


def test_get_movies_by_director():
    assert '<NAME>' in director_movies
    assert len(director_movies['<NAME>']) == 4
    assert len(director_movies['<NAME>']) == 12


def test_director_movies_data_structure():
    assert type(director_movies) in (dict, defaultdict)
    assert type(director_movies['<NAME>']) == list
    assert type(director_movies['<NAME>'][0]) == Movie


def test_calc_mean_score():
    movies_sergio = director_movies['<NAME>']
    movies_nolan = director_movies['<NAME>']
    assert calc_mean_score(movies_sergio) == 8.5
    assert calc_mean_score(movies_nolan) == 8.4


def test_get_average_scores():
    avg_scores = get_average_scores(director_movies)[:10]
    expected = [('<NAME>', 8.5),
                ('<NAME>', 8.4),
                ('<NAME>', 8.2),
                ('<NAME>', 8.2),
                ('<NAME>', 8.0),
                ('<NAME>', 8.0),
                ('<NAME>', 7.9),
                ('<NAME>', 7.9),
                ('<NAME>', 7.8),
                ('<NAME>', 7.8)]
    assert avg_scores == expected
