示例#1
0
def test_update_author():
    a = Author(db=db, email='test', subdomain='test')
    a.save()
    assert Author().load(a.url, db=db).email == 'test'

    a.email = 'changed'
    a.save()
    assert Author().load(a.url, db=db).email == 'changed'
示例#2
0
def test_subdomain_validation():

    toolong = 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'
    badchars = 'dd-me'

    assert Author.valid_subdomain('good')
    assert not Author.valid_subdomain(toolong)
    assert not Author.valid_subdomain(badchars)

    #254 characters long
    domain = dustbin.config.domain
    dustbin.config.domain = 'uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu'
    assert not Author.valid_subdomain('good'), 'Domain was too long, this should fail a validation check'
    dustbin.config.domain = domain
示例#3
0
def test_subdomain_validation():

    toolong = 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'
    badchars = 'dd-me'

    assert Author.valid_subdomain('good')
    assert not Author.valid_subdomain(toolong)
    assert not Author.valid_subdomain(badchars)

    #254 characters long
    domain = dustbin.config.domain
    dustbin.config.domain = 'uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu'
    assert not Author.valid_subdomain(
        'good'), 'Domain was too long, this should fail a validation check'
    dustbin.config.domain = domain
示例#4
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"
示例#5
0
def test_update_author():
    a = Author(db=db, email='test', subdomain='test')
    a.save()
    assert Author().load(a.url, db=db).email == 'test'
    
    a.email = 'changed'
    a.save()
    assert Author().load(a.url, db=db).email == 'changed'
示例#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 create_feed(now=None):
    author = Author(subdomain='potter',
                     email='*****@*****.**')\
                     .save(db=db)
    if not now:
        now = dt.now()
    return Feed(title='pics',
                links=[{
                    'href': 'http://www.google.com',
                    'rel': 'self'
                }, {
                    'href': 'http://www.yahoo.com'
                }],
                updated=now,
                author=author,
                url='/potter/private/pics/posts',
                db=db)
示例#8
0
def test_add_author():
    a = Author(email='*****@*****.**',
                subdomain='sean')
    a.save(db=db)
    b = Author().load(a.url, db=db)
    assert a == b, "Author wasn't saved correctly"

    a = Author(db=db)
    assert_raises(Exception, a.save)

    a = Author(db=db, email='test')
    assert_raises(Exception, a.save)

    a = Author(db=db, subdomain='test')
    assert_raises(Exception, a.save)

    a = Author(db=db, email='test', subdomain='invalid subdomain')
    assert_raises(Exception, a.save)
示例#9
0
def test_author_url():

    a = Author(email='test', subdomain='test')
    assert a.url == '/test'
示例#10
0
def test_add_author():
    a = Author(email='*****@*****.**', subdomain='sean')
    a.save(db=db)
    b = Author().load(a.url, db=db)
    assert a == b, "Author wasn't saved correctly"

    a = Author(db=db)
    assert_raises(Exception, a.save)

    a = Author(db=db, email='test')
    assert_raises(Exception, a.save)

    a = Author(db=db, subdomain='test')
    assert_raises(Exception, a.save)

    a = Author(db=db, email='test', subdomain='invalid subdomain')
    assert_raises(Exception, a.save)