示例#1
0
def test_load_from_db():
    '''
    Make sure we can save and rehydrate
    a post instance from the database.
    '''
    post = Post(content='test this out',
                title='super awesome title',
                author = author,
                prefix=prefix,
                db=db)
    post.save()
    saved = Post(db=db).load(post.url + '.json')
    assert saved == post
示例#2
0
def test_post_save():
    '''
    saving a post should:
    1. update feeds (tested in feed test module)
    2. create a json entry at the url
    3. create an html fragment entry at the url.html
    '''
    content = 'check it'
    post = Post(content=content, prefix=prefix, db=db, author=author)
    post.save()
    newpost = Post(db=db).load(post.url + '.json')
    assert newpost == post
    assert post.fragment == db.get(post.url + '.html')
示例#3
0
def test_load_from_db():
    '''
    Make sure we can save and rehydrate
    a post instance from the database.
    '''
    post = Post(content='test this out',
                title='super awesome title',
                author=author,
                prefix=prefix,
                db=db)
    post.save()
    saved = Post(db=db).load(post.url + '.json')
    assert saved == post
示例#4
0
def test_post_save():
    '''
    saving a post should:
    1. update feeds (tested in feed test module)
    2. create a json entry at the url
    3. create an html fragment entry at the url.html
    '''
    content = 'check it'
    post = Post(content=content, prefix=prefix, db=db, author=author)
    post.save()
    newpost = Post(db=db).load(post.url + '.json')
    assert newpost == post
    assert post.fragment == db.get(post.url + '.html')
示例#5
0
def test_new_post_updates():
    #creating a new post updates lense
    #feed and author feed
    lense = test_create_lense()
    assert len(lense.feed.entries) == 0
    assert len(lense.author.feed.entries) == 0
    post = Post('test this shit out',
                prefix='/sean/public/%s/posts' % lense.name,
                author=lense.author,
                lense=lense)
    post.save(db=db)
    lense.update()
    assert len(lense.feed.entries) == 1
    assert len(lense.author.feed.entries) == 1
    post.delete()
    lense.update()
    assert len(lense.feed.entries) == 0
    assert len(lense.author.feed.entries) == 0
示例#6
0
def test_new_post_updates():
    #creating a new post updates lense
    #feed and author feed
    lense = test_create_lense()
    assert len(lense.feed.entries) == 0
    assert len(lense.author.feed.entries) == 0
    post = Post('test this shit out',
                prefix='/sean/public/%s/posts' % lense.name,
                author=lense.author,
                lense=lense)
    post.save(db=db)
    lense.update()
    assert len(lense.feed.entries) == 1
    assert len(lense.author.feed.entries) == 1
    post.delete()
    lense.update()
    assert len(lense.feed.entries) == 0
    assert len(lense.author.feed.entries) == 0