def test_successful_question_delete(self): mock_question_id = create_mock_question() response = self.client().delete('/questions/{}'.format(mock_question_id)) data = json.loads(response.data) self.assertEqual(response.status_code, 200) self.assertEqual(data['success'], True) self.assertEqual(data['message'], "Question successfully deleted")
def test_delete_same_question_twice(self): mock_question_id = create_mock_question() self.client().delete('/questions/{}'.format(mock_question_id)) response = self.client().delete('/questions/{}'.format(mock_question_id)) data = json.loads(response.data) self.assertEqual(response.status_code, 422) self.assertEqual(data['success'], False) self.assertEqual(data['message'], 'Unprocessable entity')
def test_delete_same_question_twice(self): mock_question_id = create_mock_question() # this tests if resource has already been deleted self.client().delete('/questions/{}'.format(mock_question_id)) response = self.client().delete( '/questions/{}'.format(mock_question_id)) data = json.loads(response.data) # make assertions on the response data self.assertEqual(response.status_code, 422) self.assertEqual(data['success'], False) self.assertEqual(data['message'], 'Unprocessable entity')
def test_successful_question_delete(self): """Test for deleting a question. create_mock_question function is used to prevent having to drop the database during the running of the test suite. """ # create mock question and get id mock_question_id = create_mock_question() # delete mock question and process response response = self.client().delete( '/questions/{}'.format(mock_question_id)) data = json.loads(response.data) # ensure question does not exist self.assertEqual(response.status_code, 200) self.assertEqual(data['success'], True) self.assertEqual(data['message'], "Question successfully deleted")