Exemplo n.º 1
0
    def test_populate_vacation_property_form_with_badformed_url_params_should_produce_error(
            self):
        form = VacationPropertyForm(description='description',
                                    image_url='image.png')

        assert form.validate() is False
        assert 'Invalid Image Url' in form.image_url.errors
def new_property():
    form = VacationPropertyForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            host = User.query.get(current_user.get_id())

            property = VacationProperty(form.description.data, form.image_url.data, host)
            db.session.add(property)
            db.session.commit()
            return redirect_to('properties')

    return view('property_new', form)
Exemplo n.º 3
0
def new_property():
    form = VacationPropertyForm()
    if request.method == "POST":
        if form.validate_on_submit():
            host = User.query.get(current_user.get_id())

            property = VacationProperty(form.description.data, form.image_url.data, host)
            db.session.add(property)
            db.session.commit()
            return redirect_to("properties")

    return view("property_new", form)
Exemplo n.º 4
0
    def test_populate_vacation_property_form_with_missing_params_should_be_ok(
            self):
        form = VacationPropertyForm(description='description')

        assert form.validate() is False
Exemplo n.º 5
0
    def test_populate_vacation_property_form_with_badformed_url_params_should_produce_error(self):
        form = VacationPropertyForm(description='description', image_url='image.png')

        assert form.validate() is False
        assert 'Invalid Image Url' in form.image_url.errors
Exemplo n.º 6
0
    def test_populate_vacation_property_form_with_missing_params_should_be_ok(self):
        form = VacationPropertyForm(description='description')

        assert form.validate() is False