コード例 #1
0
    def test_list_faq_method_returns_faqs(self):
        with self.app.app_context():
            new_faq = FaqFactory.create()
            faq_controller = FaqController(self.request_context)

            response = faq_controller.list_faqs()

            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.get_json()['msg'], 'OK')
            self.assertEqual(response.get_json()['payload']['faqs'][0]['id'],
                             new_faq.id)
コード例 #2
0
    def test_list_faq_method_captures_invalid_dates(self):

        with self.app.app_context():
            faq_controller = FaqController(self.request_context)

            response = faq_controller.list_faqs(
                created_at='2019-04-04-invalid')

            self.assertEqual(response.status_code, 400)
            self.assertEqual(
                response.get_json()['msg'],
                'Bad Request - created_at should be valid date. Format: YYYY-MM-DD'
            )
コード例 #3
0
    def test_list_faq_method_captures_invalid_category_values(
            self, mock_filter_by):
        with self.app.app_context():
            mock_filter_by.side_effect = DataError('statement', 'params',
                                                   'orig')

            faq_controller = FaqController(self.request_context)

            response = faq_controller.list_faqs(category='2019-04-04-invalid')

            self.assertEqual(response.status_code, 400)
            self.assertEqual(
                response.get_json()['msg'],
                "Category should be one of these values ['user_faq', 'admin_faq']"
            )