def motivation(): with db: stories_by_tags = Story.tags_mapping() return render_template('motivation.html', nav_active='motivation', subnav_tabs=HANDBOOK_SUBNAV_TABS, subnav_active='motivation', stories_by_tags=stories_by_tags, thumbnail=thumbnail(title='Proč se učit programování'))
def test_tags_mapping(db_connection): story1 = create_story(date=date(2010, 7, 6), tags=['science', 'age']) story2 = create_story(date=date(2019, 7, 6), tags=['science', 'careerswitch']) story3 = create_story(date=date(2014, 7, 6), tags=['age', 'careerswitch']) mapping = Story.tags_mapping() assert set(mapping.keys()) == {'age', 'science', 'careerswitch'} assert mapping['age'] == [story3, story1] assert mapping['science'] == [story2, story1] assert mapping['careerswitch'] == [story2, story3]