Ejemplo n.º 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'
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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"
Ejemplo n.º 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'
Ejemplo n.º 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"
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 9
0
def test_author_url():

    a = Author(email='test', subdomain='test')
    assert a.url == '/test'
Ejemplo n.º 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)