def test_show_with_chapters(app, db): with app.test_client() as client: db.session.add( Series(id=1, title='Peanuts', author='Charles M. Schulz')) db.session.add( Chapter(id=1, title='Strip #1', pubdate=datetime(1950, 10, 2), atom_id='atom1', series_id=1)) db.session.add( Chapter(id=2, title='Strip #2', pubdate=datetime(1950, 10, 3), atom_id='atom2', series_id=1)) db.session.commit() d = client.get('/feeds/1.xml').doc ns = {'a': 'http://www.w3.org/2005/Atom'} assert cache.get(feed_cache_key(1)) is not None assert d.xpath('a:title/text()', namespaces=ns) == ['Peanuts'] assert (d.xpath('a:author/a:name/text()', namespaces=ns) == ['Charles M. Schulz']) assert d.xpath('count(a:entry)', namespaces=ns) == 2 assert (d.xpath('a:entry/a:id/text()', namespaces=ns) == ['atom2', 'atom1'])
def test_show_with_chapters(app, db): with app.test_client() as client: db.session.add(Series( id=1, title='Peanuts', author='Charles M. Schulz')) db.session.add(Chapter( id=1, title='Strip #1', pubdate=datetime(1950, 10, 2), atom_id='atom1', series_id=1)) db.session.add(Chapter( id=2, title='Strip #2', pubdate=datetime(1950, 10, 3), atom_id='atom2', series_id=1)) db.session.commit() d = client.get('/feeds/1.xml').doc ns = {'a': 'http://www.w3.org/2005/Atom'} assert cache.get(feed_cache_key(1)) is not None assert d.xpath('a:title/text()', namespaces=ns) == ['Peanuts'] assert (d.xpath('a:author/a:name/text()', namespaces=ns) == ['Charles M. Schulz']) assert d.xpath('count(a:entry)', namespaces=ns) == 2 assert (d.xpath('a:entry/a:id/text()', namespaces=ns) == ['atom2', 'atom1'])
def test_index_with_empty_db(app, db): with app.test_client() as client: d = client.get('/').doc assert cache.get(index_cache_key()) is not None assert d.cssselect('.no-feeds')[0].text == '구독할 수 있는 웹툰이 없습니다.' assert d.cssselect('.series') == []
def test_index_with_empty_db(app, db): with app.test_client() as client: d = client.get('/').doc assert cache.get(index_cache_key()) is not None assert d.cssselect('.no-feeds')[0].text == u'구독할 수 있는 웹툰이 없습니다.' assert d.cssselect('.series') == []