vendredi 6 février 2015

Testing methods post on the form using django-webtest

I want to test my form using django-webtest. I want to create an object (make post) using the form. But I get the error on the amount of:



my_form.form['country'].value = "USA"


My all test:



def test_post_view(self):
my_form = self.app.get(reverse('myapp:add_page'), user=self.user)
my_form.form['country'].value = "USA"
my_form.form['name'].value = "Christmas"
my_form.form['date_from'].value = timezone.now()
my_form.form['date_to'].value = timezone.now() + datetime.timedelta(days=5)
my_form.form.submit()


My form:



class MyInputForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ('country', 'name', 'date_from', 'date_to',)

Aucun commentaire:

Enregistrer un commentaire