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
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
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"
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')
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)
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"
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
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)
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)
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)
def test_lense_json(): lense = test_create_lense() jsons = lense.json fromjson = Lense(**json.loads(jsons)) assert fromjson == lense