0

I have a simple test:

def test_project_info_form_post_submission(self):
    """
    Test if project info form can be submitted via post.
    """
    # set up our POST data
    post_data = {
        'zipcode': '90210',
        'module': self.module1.pk,
        'model': self.model1.pk,
        'orientation': 1,
        'tilt': 1,
        'rails_direction': 1,
    }
    ...
    response = self.client.post(reverse(url), post_data)
    self.assertEqual(response.status_code, 302)

    # test empty form
    response = self.client.post(reverse(url))
    self.assertEqual(response.status_code, 200)
    #! test for general form error message 

    # now test invalid responses
    post_data['zipcode'] = 'abcdefg'
    response = self.client.post(reverse(url), post_data)
    self.assertEqual(response.status_code, 200)
    #! test for specific error message associated with zipcode

So the lines I am having trouble with are marked with shebangs. I know I should have messages in the context variable but can't seem to figure out the right ones to use.

1 Answer 1

1

You can test if the template contains your message in your TestCase with assertContains.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.