-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_facets.py
32 lines (26 loc) · 1.04 KB
/
test_facets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Test file for facet search method written in db.py
All test methods must receive client as an argument,
otherwise the database variable won't be configured correctly
"""
import pytest
from mflix.db import get_movies_faceted
@pytest.mark.facets
def test_faceted_search_should_return_rating_and_runtime_buckets(client):
filter = {'cast': ['Tom Hanks']}
result = get_movies_faceted(filter, 0, 20)
# expecting the first entry in the returned tuple to be a dictionary with
# the key 'movies'
assert len(result[0]['movies']) == 20
assert len(result[0]['rating']) == 5
assert len(result[0]['runtime']) == 4
# expecting the second entry in the returned tupe to be the number of results
assert result[1] == 51
@pytest.mark.facets
def test_faceted_search_should_also_support_paging(client):
filter = {'cast': ['Susan Sarandon'], }
result = get_movies_faceted(filter, 3, 20)
assert(len(result[0]['movies'])) == 3
assert len(result[0]['rating']) == 1
assert len(result[0]['runtime']) == 2
assert result[1] == 63