def test_repository_can_add_a_tag(session_factory): repo = SqlAlchemyRepository(session_factory) tag = Tag('Motoring') repo.add_tag(tag) assert tag in repo.get_tags()
def test_repository_can_retrieve_tags(session_factory): repo = SqlAlchemyRepository(session_factory) tags = repo.get_tags() assert len(tags) == 10 tag_one = [tag for tag in tags if tag.tag_name == 'New Zealand'][0] tag_two = [tag for tag in tags if tag.tag_name == 'Health'][0] tag_three = [tag for tag in tags if tag.tag_name == 'World'][0] tag_four = [tag for tag in tags if tag.tag_name == 'Politics'][0] assert tag_one.number_of_tagged_articles == 53 assert tag_two.number_of_tagged_articles == 2 assert tag_three.number_of_tagged_articles == 64 assert tag_four.number_of_tagged_articles == 1