def should_be_callable_when_has_correct_permissions(self, user, url=None):
if not url:<EOL><INDENT>url = self.get_url()<EOL><DEDENT>user_no_permissions = AnonymousUser()<EOL>self.login(user_no_permissions)<EOL>resp = self.client.get(url, data=self.get_data_payload())<EOL>self.assertRedirects(resp, '<STR_LIT>'.format(<EOL>reverse('<STR_LIT>'), url))<EOL>self.login(user)<EOL>resp = self.client.get(url, data=self.get_data_payload())<EOL>self.assertEqual(resp.status_code, <NUM_LIT:200>)<EOL>
Tests if the view returns 200 when the user has permissions.

Also tests if the view redirects to login if the user is logged in but
does not have the correct permissions.

:param user: A ``User`` instance that has the correct permissions.
:param url: A string representing the URL to be called. If ``None``,
  the return value of ``get_url()`` will be used.