def test_repository_returns_an_empty_list_for_non_existent_ids( session_factory): repo = SqlAlchemyRepository(session_factory) articles = repo.get_articles_by_id([0, 199]) assert len(articles) == 0
def test_repository_does_not_retrieve_article_for_non_existent_id( session_factory): repo = SqlAlchemyRepository(session_factory) articles = repo.get_articles_by_id([2, 209]) assert len(articles) == 1 assert articles[ 0].title == 'Covid 19 coronavirus: US deaths double in two days, Trump says quarantine not necessary'
def test_repository_can_get_articles_by_ids(session_factory): repo = SqlAlchemyRepository(session_factory) articles = repo.get_articles_by_id([2, 5, 6]) assert len(articles) == 3 assert articles[ 0].title == 'Covid 19 coronavirus: US deaths double in two days, Trump says quarantine not necessary' assert articles[ 1].title == "Australia's first coronavirus fatality as man dies in Perth" assert articles[ 2].title == 'Coronavirus: Death confirmed as six more test positive in NSW'