Advertisement
Guest User

test_crud_methods_on_submissions

a guest
Dec 20th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. @tag('incomplete') # Weird TypeError in question_answers under post method
  2. def test_crud_methods_on_submissions(self):
  3. # Tests that we can retrieve a list of submissions using get method
  4. self.client.login(username='user', password='pass')
  5. resp = self.client.get(path=reverse('api:submission-list', kwargs={'version': 'v1'}))
  6. assert resp.status_code == 200
  7.  
  8. # Tests that we can post a new submission
  9. string = self.question.answer
  10. byte_string = str.encode(string)
  11. print(isinstance(byte_string, bytes))
  12. resp = self.client.post(path=reverse('api:submission-list', kwargs={'version': 'v1'}),
  13. data={"klass": self.klass.pk,
  14. "definition": self.definition.pk,
  15. "creator": self.instructor.pk,
  16. "submission_github_url": "",
  17. "method_name": "",
  18. "method_description": "",
  19. "project_url": "",
  20. "publication_url": "",
  21. "question_answers": byte_string})
  22. print(resp.content)
  23. assert resp.status_code == 201
  24.  
  25. # Tests that we can't change any submissions info using put method
  26. resp = self.client.put(path=reverse('api:submission-detail', kwargs={'version': 'v1', 'pk': '2'}),
  27. data={"klass": '',
  28. "definition": '',
  29. "creator": '',
  30. "submission_github_url": "",
  31. "method_name": "",
  32. "method_description": "",
  33. "project_url": "",
  34. "publication_url": "",
  35. "question_answers": ''},
  36. content_type='application/json')
  37. assert resp.status_code == 200
  38.  
  39. # Tests that we can't delete any submissions
  40. resp = self.client.delete(path=reverse('api:submission-detail', kwargs={'version': 'v1', 'pk': '2'}))
  41. assert resp.status_code == 204
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement