def test_news_years(town_app): collection = PageCollection(town_app.session()) news = collection.add_root("News", type='news') one = collection.add(news, title="One", type='news') two = collection.add(news, title="Two", type='news') assert news.years == [datetime.utcnow().year] one.created = datetime(2016, 2, 1, tzinfo=pytz.utc) two.created = datetime(2015, 2, 1, tzinfo=pytz.utc) assert news.years == [2016, 2015]
def add_root_pages(session): pages = PageCollection(session) pages.add_root( "Leben & Wohnen", name='leben-wohnen', type='topic', meta={'trait': 'page'} ), pages.add_root( "Kultur & Freizeit", name='kultur-freizeit', type='topic', meta={'trait': 'page'} ), pages.add_root( "Bildung & Gesellschaft", name='bildung-gesellschaft', type='topic', meta={'trait': 'page'} ), pages.add_root( "Gewerbe & Tourismus", name='gewerbe-tourismus', type='topic', meta={'trait': 'page'} ), pages.add_root( "Politik & Verwaltung", name='politik-verwaltung', type='topic', meta={'trait': 'page'} ) pages.add_root( "Aktuelles", name='aktuelles', type='news', meta={'trait': 'news'} )