Example #1
0
def test_get_edit_shoud_return_200(app, client):
    with app.app_context():
        user_repository.create('dude', '1234')
    client.post('/login', data={'username': '******', 'password': '******'})

    rv = client.get('/profile/edit')
    assert rv.status_code == 200
Example #2
0
def test_should_show_profile_after_update(app, client):
    with app.app_context():
        user_repository.create('dude', '1234')
    client.post('/login', data={'username': '******', 'password': '******'})
    client.post('/profile/edit', data={'username': '******', 'bio': '# Welcome'})

    rv = client.get('/profile/')
    assert rv.status_code == 200
Example #3
0
def test_should_not_update_username(app, client):
    with app.app_context():
        id = user_repository.create('dude', '1234').id
        user_repository.create('foo', 'bar')
    client.post('/login', data={'username': '******', 'password': '******'})

    rv = client.post('/profile/edit', data={'username': '******'})
    assert rv.status_code == 200
    with app.app_context():
        user = user_repository.find(id)
    assert user.username == 'dude'
Example #4
0
def test_should_update_username(app, client):
    with app.app_context():
        id = user_repository.create('dude', '1234').id
    client.post('/login', data={'username': '******', 'password': '******'})

    rv = client.post('/profile/edit', data={'username': '******'})
    assert rv.status_code == 302
    assert rv.headers['Location'] == 'http://localhost/profile/'
    with app.app_context():
        user = user_repository.find(id)
    assert user.username == 'woa'
Example #5
0
def test_should_not_update_password(app, client):
    with app.app_context():
        u = user_repository.create('dude', '1234')
        old_password_hash = u.password
    client.post('/login', data={'username': '******', 'password': '******'})

    rv = client.post('/profile/edit',
                     data={
                         'username': '******',
                         'new_password': '******'
                     })
    assert rv.status_code == 200
    with app.app_context():
        user = user_repository.find(u.id)
        assert user.password == old_password_hash
Example #6
0
def test_should_update_bio_and_photo(app, client):
    with app.app_context():
        u = user_repository.create('dude', '1234')
        old_bio = u.bio
        old_photo = u.photo
    client.post('/login', data={'username': '******', 'password': '******'})

    rv = client.post('/profile/edit',
                     data={
                         'username': '******',
                         'bio': 'LOL',
                         'photo': 'http://'
                     })
    assert rv.status_code == 302
    with app.app_context():
        user = user_repository.find(u.id)
        assert user.bio != old_bio
        assert user.photo != old_photo
Example #7
0
 def create_user(username, password):
     user_repository.create(username, password)
     click.echo('Created user {}'.format(username))