예제 #1
0
def test_delete_post():

    tearDown()
    author = create_author(db)
    l = Lense(name = 'facebook',
              subdomain=SUBDOMAIN,
              db=db,
              author=author).save()

    assert len(l.feed.entries) == 0
    assert len(author.feed.entries) == 0
    
    post = Post(content='test this out',
                title='super awesome title',
                author = author,
                prefix=l.feed.url,
                db=db,
                lense=l).save()

    l.update()
    author.update()
    assert len(l.feed.entries) == 1
    assert len(author.feed.entries) == 1

    post.delete()
    l.update()
    author.update()
    assert len(l.feed.entries) == 0
    assert len(author.feed.entries) == 0
예제 #2
0
def test_create_lense():

    author = create_author(db)
    l = Lense(name='facebook', subdomain=SUBDOMAIN, db=db,
              author=author).save()
    loaded = Lense().load(l.url, db=db)
    assert loaded == l
    return l
예제 #3
0
def test_get_lenses():
    a = Author(email='*****@*****.**', subdomain='sean')
    a.save(db=db)
    assert len(a.lenses) == 0
    l = Lense(name='facebook', subdomain=SUBDOMAIN, db=db, author=a).save()
    a.update()
    assert len(a.lenses) == 1
    l.delete()
    a.update()
    assert len(a.lenses) == 0, "failed to delete lense"
예제 #4
0
def test_lense_url():
    l = Lense(name='facebook',
              subdomain=SUBDOMAIN,
              db=db,
              author=create_author(db))
    assert l.url == "/%s/%s/%s" % (SUBDOMAIN, 'public', 'facebook')
    l = Lense(name='facebookistan',
              subdomain=SUBDOMAIN,
              db=db,
              public=False,
              author=create_author(db))
    assert l.url == "/%s/%s/%s" % (SUBDOMAIN, 'private', 'facebookistan')
예제 #5
0
def test_create_lense_same_name():

    author = create_author(db)
    l = Lense(name='facebook',
              subdomain=SUBDOMAIN,
              db=db,
              author=author)
    l.save()
    l = Lense(name='facebook',
              subdomain=SUBDOMAIN,
              db=db,
              public=False,
              author=author)
    assert_raises(AssertionError, l.save)
예제 #6
0
def test_get_lenses():
    a = Author(email='*****@*****.**',
                subdomain='sean')
    a.save(db=db)
    assert len(a.lenses) == 0
    l = Lense(name = 'facebook',
              subdomain=SUBDOMAIN,
              db=db,
              author=a).save()
    a.update()
    assert len(a.lenses) == 1
    l.delete()
    a.update()
    assert len(a.lenses) == 0, "failed to delete lense"
예제 #7
0
def test_delete_post():

    tearDown()
    author = create_author(db)
    l = Lense(name='facebook', subdomain=SUBDOMAIN, db=db,
              author=author).save()

    assert len(l.feed.entries) == 0
    assert len(author.feed.entries) == 0

    post = Post(content='test this out',
                title='super awesome title',
                author=author,
                prefix=l.feed.url,
                db=db,
                lense=l).save()

    l.update()
    author.update()
    assert len(l.feed.entries) == 1
    assert len(author.feed.entries) == 1

    post.delete()
    l.update()
    author.update()
    assert len(l.feed.entries) == 0
    assert len(author.feed.entries) == 0
예제 #8
0
def test_delete_author():
    author = create_author(db)
    af = author.feed
    l = Lense(name='facebook', subdomain=SUBDOMAIN, db=db,
              author=author).save()

    post = Post(content='test this out',
                title='super awesome title',
                author=author,
                prefix=l.feed.url,
                db=db,
                lense=l).save()
    l.update()
    author.update()
    assert len(l.feed.entries) == 1
    assert len(author.feed.entries) == 1

    author.delete()
    assert_raises(Exception, db.get, author.url)
    assert_raises(Exception, db.get, l.url)
    assert_raises(Exception, db.get, post.url)
    assert_raises(Exception, db.get, af.url)
예제 #9
0
def test_delete_author():
    author = create_author(db)
    af = author.feed
    l = Lense(name = 'facebook',
              subdomain=SUBDOMAIN,
              db=db,
              author=author).save()

    post = Post(content='test this out',
                title='super awesome title',
                author = author,
                prefix=l.feed.url,
                db=db,
                lense=l).save()
    l.update()
    author.update()
    assert len(l.feed.entries) == 1
    assert len(author.feed.entries) == 1

    author.delete()
    assert_raises(Exception, db.get, author.url)
    assert_raises(Exception, db.get, l.url)
    assert_raises(Exception, db.get, post.url)
    assert_raises(Exception, db.get, af.url)
예제 #10
0
def test_create_lense_same_name():

    author = create_author(db)
    l = Lense(name='facebook', subdomain=SUBDOMAIN, db=db, author=author)
    l.save()
    l = Lense(name='facebook',
              subdomain=SUBDOMAIN,
              db=db,
              public=False,
              author=author)
    assert_raises(AssertionError, l.save)
예제 #11
0
def test_name_is_posts():
    #shouldn't be able to name it posts
    author = create_author(db)
    l = Lense(name='posts', subdomain=SUBDOMAIN, db=db, author=author)
    assert_raises(AssertionError, l.save)
예제 #12
0
def test_lense_json():
    lense = test_create_lense()
    jsons = lense.json
    fromjson = Lense(**json.loads(jsons))
    assert fromjson == lense