Example #1
0
 def test_update_groups_with_timeout(self, mock_patch):
     mock_patch.side_effect = Timeout(self.error_msg)
     with app.app_context() as ac:
         ac.g.trace_id = None
         ac.g.requests = requests.Session()
         with app.test_request_context():
             with self.assertRaises(ApplicationError) as context:
                 AccountAPI.update_groups(self, '1234-567-890', {"nps": True})
                 self.assertTrue(ApplicationError in str(context.exception))
             self.assertEqual(context.exception.message,
                              'Connection to account_api timed out: {}'.format(self.error_msg))
             self.assertEqual(context.exception.code, 'E503')
             self.assertEqual(context.exception.http_code, 500)
Example #2
0
    def test_update_groups_http_error(self, mock_patch):
        with app.app_context() as ac:
            ac.g.trace_id = None
            ac.g.requests = requests.Session()
            with app.test_request_context():
                mock_patch.side_effect = HTTPError(self.error_msg)

                with self.assertRaises(ApplicationError) as context:
                    AccountAPI.update_groups(self, '1234-567-890', {"nps": True})

                self.assertEqual(context.exception.message,
                                 'Received the following response from account_api: {}'.format(self.error_msg))
                self.assertEqual(context.exception.code, 'E501')
                self.assertEqual(context.exception.http_code, 500)
Example #3
0
 def test_update_groups(self, mock_patch):
     with app.app_context() as ac:
         ac.g.trace_id = None
         ac.g.requests = requests.Session()
         with app.test_request_context():
             mock_patch.return_value.text = 'Success'
             mock_patch.return_value.status_code = 200
             response = AccountAPI.update_groups(self, '1234-567-890', {"nps": True})
             self.assertEqual(response, {'message': 'groups updated'})