import pytest
from sqlalchemy.orm import Session

from itunesdb.web import crud
from itunesdb.web import models


@pytest.fixture
def db_two_albums_each_with_two_tracks(
    db: Session,
    track_1_ambient_1: models.Track,
    track_1_ambient_2: models.Track,
    track_2_ambient_1: models.Track,
    track_2_ambient_2: models.Track,
) -> Session:

    return db


def test_retrieves_all_tracks_from_album_and_no_more(
    db_two_albums_each_with_two_tracks: Session,
    track_1_ambient_1: models.Track,
    track_2_ambient_1: models.Track,
):
    tracks = crud.get_tracks(
        track_1_ambient_1.album_id, db_two_albums_each_with_two_tracks
    )

    assert len(tracks) == 2
    assert track_1_ambient_1 in tracks
    assert track_2_ambient_1 in tracks


def test_non_existent_album_id(db: Session):
    tracks = crud.get_tracks(1, db)
    assert not len(tracks)

import pytest
from sqlalchemy.orm import Session

from itunesdb.web import crud
from itunesdb.web import models


@pytest.fixture
def db_two_albums_each_with_two_tracks(
    db: Session,
    track_1_ambient_1: models.Track,
    track_1_ambient_2: models.Track,
    track_2_ambient_1: models.Track,
    track_2_ambient_2: models.Track,
) -> Session:

    return db


def test_retrieves_all_tracks_from_album_and_no_more(
    db_two_albums_each_with_two_tracks: Session,
    track_1_ambient_1: models.Track,
    track_2_ambient_1: models.Track,
):
    tracks = crud.get_tracks(
        track_1_ambient_1.album_id, db_two_albums_each_with_two_tracks
    )

    assert len(tracks) == 2
    assert track_1_ambient_1 in tracks
    assert track_2_ambient_1 in tracks


def test_non_existent_album_id(db: Session):
    tracks = crud.get_tracks(1, db)
    assert not len(tracks)
