예제 #1
0
def test_config():
    config = Config.instance()
    lastrun = config.update()
    session.commit()
    time.sleep(1)
    config = Config.instance()
    assert config.lastrun == lastrun
예제 #2
0
def test_entry_creation():
    NewsEntry(
        id="foo",
        title="title",
        teaser_image = "\x00" * 1000,
        valid=True,
        category="top",
        abstract="abstract",
        )
    session.commit()
                      
    entry = NewsEntry.get("foo")
    assert entry.title == "title"
예제 #3
0
def test_news_sampling():
    fake_news(STANDARD_DISTRIBUTION)
    session.commit()
    res = sample()
    for c, num in STANDARD_DISTRIBUTION.iteritems():
        assert len(res[c]) == num

    try:
        count = NewsEntry.query.count()
        d = dict((c, count) for c, _ in STANDARD_DISTRIBUTION.iteritems())

        sample(d)
    except CantSampleEnough:
        pass
    else:
        assert Fail, "Shouldn't be able to sample this"
예제 #4
0
def test_news_fetching():
    Config.PAUSE = timedelta(seconds=-10)
    fetch_news()
    session.commit()
    for entry in NewsEntry.query.all():
        pass