Esempio n. 1
0
def test_like_a_movie():
    service.add_user('haly', '6666', repo)
    user = service.get_user('haly', repo)
    service.like('0', 'haly', repo)
    assert len(user.favorite) == 1
    assert user.favorite[0].ID == '0'
    repo.db.data.dataset_of_user.pop(-1)
    repo.db.data.write_user()
Esempio n. 2
0
def register():
    form = RegistrationForm()
    username_not_unique = None
    if form.validate_on_submit():
        try:
            service.add_user(form.username.data, form.password.data, repo)

            # All is well, redirect the user to the login page.
            return redirect(url_for('user_bp.login'))
        except service.NameNotUniqueException:
            username_not_unique = 'Your username is already taken - please supply another'

    # For a GET or a failed POST request, return the Registration Web page.
    return render_template(
        'User/register.html',
        title='Register',
        form=form,
        username_error_message=username_not_unique,
        handler_url=url_for('user_bp.register'),
    )
Esempio n. 3
0
def test_add_user_with_exist_name():
    try:
        service.add_user('ekelien', 'momomomomo', repo)
        assert False
    except:
        assert True
Esempio n. 4
0
def test_add_user():
    service.add_user('haly', '6666', repo)
    user = service.get_user('haly', repo)
    assert user.name == 'haly'
    repo.db.data.dataset_of_user.pop(-1)
    repo.db.data.write_user()