Exemplo n.º 1
0
def test_index_with_series(app, db):
    with app.test_client() as client:
        db.session.add(
            Series(id=1, title='Peanuts', author='Charles M. Schulz'))
        db.session.add(
            Series(
                id=2,
                title="Alice's Adventures in Wonderland",
                author='Lewis Carroll',
                description='A girl named Alice falls down a rabbit hole into a '
                'fantasy world.'))
        db.session.commit()

        d = client.get('/').doc
        a1 = d.cssselect('#series-1')[0]
        assert a1.cssselect('.series-title a')[0].text.strip() == 'Peanuts'
        assert a1.cssselect('.series-author')[0].text == 'Charles M. Schulz'

        a2 = d.cssselect('#series-2')[0]
        assert (a2.cssselect('.series-title a')[0].text.strip() ==
                "Alice's Adventures in Wonderland")
        assert a2.cssselect('.series-author')[0].text == 'Lewis Carroll'
        assert (a2.cssselect('.series-description')[0].text ==
                'A girl named Alice falls down a rabbit hole into a fantasy '
                'world.')
        assert d.cssselect('.no-feeds') == []
        assert len(d.cssselect('.series')) == 2
        assert ([e.attrib['id'] for e in d.cssselect('.series')
                 ] == ['series-2',
                       'series-1']), 'Series should be sorted by title.'
        assert (a1.cssselect('.series-feed-url input')[0].attrib['value'] ==
                externalize_filter(url_for('feeds.show', series_id=1)))
Exemplo n.º 2
0
def test_index_with_series(app, db):
    with app.test_client() as client:
        db.session.add(Series(
            id=1,
            title='Peanuts',
            author='Charles M. Schulz'))
        db.session.add(Series(
            id=2,
            title="Alice's Adventures in Wonderland",
            author='Lewis Carroll',
            description='A girl named Alice falls down a rabbit hole into a '
                        'fantasy world.'))
        db.session.commit()

        d = client.get('/').doc
        a1 = d.cssselect('#series-1')[0]
        assert a1.cssselect('.series-title a')[0].text.strip() == 'Peanuts'
        assert a1.cssselect('.series-author')[0].text == 'Charles M. Schulz'

        a2 = d.cssselect('#series-2')[0]
        assert (a2.cssselect('.series-title a')[0].text.strip() ==
                "Alice's Adventures in Wonderland")
        assert a2.cssselect('.series-author')[0].text == 'Lewis Carroll'
        assert (a2.cssselect('.series-description')[0].text ==
                'A girl named Alice falls down a rabbit hole into a fantasy '
                'world.')
        assert d.cssselect('.no-feeds') == []
        assert len(d.cssselect('.series')) == 2
        assert ([e.attrib['id'] for e in d.cssselect('.series')] ==
                ['series-2', 'series-1']), 'Series should be sorted by title.'
        assert (a1.cssselect('.series-feed-url input')[0].attrib['value'] ==
                externalize_filter(url_for('feeds.show', series_id=1)))
Exemplo n.º 3
0
def test_externalize_with_usual_server_name(app):
    with app.test_client():
        app.config['SERVER_NAME'] = 'example.com'
        assert externalize_filter('/q?v=1') == 'http://example.com/q?v=1'
Exemplo n.º 4
0
def test_externalize(app):
    with app.test_client():
        assert externalize_filter('/a/b') == 'http://localhost:5000/a/b'
Exemplo n.º 5
0
def test_externalize_with_https(app):
    with app.test_client():
        app.config['SERVER_NAME'] = 'example.com'
        app.config['PREFERRED_URL_SCHEME'] = 'https'
        assert externalize_filter('/foo') == 'https://example.com/foo'