Esempio n. 1
0
def test_feeds_table(db, newsblur, instapaper):
    "check that a feeds table is created"
    ingest_feed(db, feed_content=newsblur)
    ingest_feed(db, feed_content=instapaper)

    # one table per feed, plus feeds
    assert len(db.tables) == 3
    assert FEEDS_TABLE in db.table_names()
    assert db[FEEDS_TABLE].count == 2
Esempio n. 2
0
def test_load_feed(db, newsblur):
    "check basic functionality"
    ingest_feed(db, feed_content=newsblur)

    assert "chrisamicos_blurblog" in db.table_names()

    table = db["chrisamicos_blurblog"]

    assert table.count == 25
Esempio n. 3
0
def test_shared_table(db, newsblur, instapaper):
    table_name = "links"
    ingest_feed(db, feed_content=newsblur, table_name=table_name)
    ingest_feed(db, feed_content=instapaper, table_name=table_name)

    # links and feeds
    assert len(db.tables) == 2
    assert FEEDS_TABLE in db.table_names()
    assert table_name in db.table_names()

    assert db[table_name].count == 35
Esempio n. 4
0
def test_transform_feed(db, instapaper):
    def capitalize(table, entry, feed_details, client=None):
        row = extract_entry_fields(table, entry, feed_details)
        row["title"] = row["title"].upper()
        return row

    ingest_feed(db, feed_content=instapaper, table_name="links", normalize=capitalize)
    feed = feedparser.parse(instapaper)

    for entry in feed.entries:
        row = db["links"].get(entry.id)
        assert row["title"] == entry["title"].upper()
Esempio n. 5
0
def test_alter_table(db, instapaper):
    def add_test_column(table, entry, feed_details, client=None):
        row = extract_entry_fields(table, entry, feed_details)
        row["extra"] = True  # this will add a column
        return row

    ingest_feed(
        db,
        feed_content=instapaper,
        table_name="links",
        normalize=add_test_column,
        alter=True,
    )

    columns = db["links"].columns_dict

    assert "extra" in columns
    assert columns["extra"] == int