Turns out there were a few things wrong.
First, there was actually a second form on the page (for selection of Product
) that I missed. Relatedly, I should have assigned ProductFactory().id
to attributes['product']
, rather than ProductFactory
.
Second, after I changed that bit, there was an issue with the assertRedirects
; I had to change self.success_url
to unicode(self.success_url)
since assertRedirects
can't perform a comparison with a proxy.
Final product:
def test_form_submission_with_valid_data_create_new_entry_and_redirects(self):
attributes = EntryFactory.attributes()
attributes['product'] = ProductFactory().id
response = self.client.post(self.form_url, attributes)
self.assertRedirects(response, unicode(self.success_url))