def test_filter_by_several_classes(client, kelly_in_math_class, kelly_in_english_class, steve_in_english_class): resp = get(client, '/students?class=1&class=2') assert len(resp) == 2 assert set(map(itemgetter('first_name'), resp)) == {'Kelly', 'Steve'}
def test_filter_by_class(client, kelly_in_math_class, kelly_in_english_class): resp = get(client, '/students?class=1') assert len(resp) == 1 assert resp[0]['first_name'] == 'Kelly'
def test_get_item(client, test_data_added, endpoint, item): js = get(client, f'{endpoint}/1') assert js == {**item, **dict(id=1)}
def test_filter_item_by_multiply_spec(client, test_data_added): resp = get(client, '/teachers?spec=math&spec=physics') assert resp for r in resp: assert 'math' in r['specs'] assert 'physics' in r['specs']
def test_filter_item_by_spec(client, test_data_added): resp = get(client, '/teachers?spec=math') assert len(resp) == 1 for r in resp: assert 'math' in r['specs']
def test_filter_item_by_last_name(client, test_data_added, endpoint, last_name, found): resp = get(client, f'{endpoint}?last_name={last_name}') assert len(resp) == found for r in resp: assert r['last_name'] == last_name