Beispiel #1
0
  def test_CreatePostWhenPostDAOThrows(self):
    postDAO = PostDAO(None)
    postDAO.create = MagicMock(side_effect=IllegalArgumentException())
    postController = PostController(postDAO)
    request = Request({ 'id': 4, 'title': self.post4.title, 'description': self.post4.description })

    response = postController.createPost(request)

    self.assertEqual(400, response.status_code)
    postDAO.create.assert_called_with(self.post4)
Beispiel #2
0
  def test_CreatePost(self):
    postDAO = PostDAO(None)
    postDAO.create = MagicMock()
    postController = PostController(postDAO)
    request = Request({ 'title': self.post4.title, 'description': self.post4.description })

    response = postController.createPost(request)

    self.assertEqual(204, response.status_code)
    postDAO.create.assert_called_with(self.post4)