def test_put_permission_fail(self, mock_update, mock_abort): """Api should return information about permission.""" with app.test_request_context(json=self.post_valid_data): mock_update.return_value = False Permission.put(1) mock_abort.assert_called_once_with(404, message=self.update_fail_msg)
def test_put_permission_success(self, mock_update): """Api should return information about permission.""" with app.test_request_context(json=self.post_valid_data): mock_update.return_value = True response = Permission.put(1) self.assertEqual(response.status_code, 201) self.assertEqual(response.json['message'], self.update_success_msg)
def test_put_permission_wrong_json(self, mock_abort): """Api should return information about permission.""" with app.test_request_context(json=self.wrong_json): Permission.put(1) mock_abort.assert_called_once_with(404, message=self.wrong_json_msg)
def test_put_permission_not_valid(self, mock_abort): """Api should return information about permission.""" with app.test_request_context(json=self.post_invalid_data): Permission.put(1) mock_abort.assert_called_once_with(404, message=self.not_valid_json_msg)