def test_create_faq_method_handles_duplicate_faq_creation(
            self, mock_request_params):
        with self.app.app_context():
            faq = FaqFactory()

            mock_request_params.return_value = [
                faq.category, faq.question, faq.answer
            ]

            faq_controller = FaqController(self.request_context)

            response = faq_controller.create_faq()

            self.assertEqual(response.status_code, 400)
            self.assertEqual(
                response.get_json()['msg'],
                "Question '{}' already exists".format(faq.question))
    def test_create_faq_method_succeeds(self, mock_request_params):
        with self.app.app_context():
            faq = FaqFactory.build()

            mock_request_params.return_value = [
                faq.category, faq.question, faq.answer
            ]

            faq_controller = FaqController(self.request_context)

            response = faq_controller.create_faq()

            self.assertEqual(response.status_code, 201)
            self.assertEqual(response.get_json()['msg'], 'OK')
            self.assertEqual(response.get_json()['payload']['faq']['question'],
                             faq.question)
            self.assertEqual(response.get_json()['payload']['faq']['answer'],
                             faq.answer)