Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. @pytest.mark.django_db
  2. @pytest.mark.django_client
  3. def test_404_nonexistent_program(client):
  4.  
  5. user_passwd = 'dummy'
  6.  
  7. user = mommy.make(User)
  8. user.set_password(user_passwd)
  9. user.save()
  10.  
  11. print client.login(username=user.username, password=user_passwd)
  12.  
  13. response = client.get("/NONEXISTENT_PROGRAM/")
  14. print response.content
  15.  
  16. # follow the redirections
  17. while response.status_code == 301 or response.status_code == 302:
  18.  
  19. response = client.get(response.get('location'))
  20. print response.content
  21.  
  22. assert response.status_code == 404
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement