'Test that management command errors out in case of fatal exceptions instead of failing silently.'

@mock.patch('requests.get')
def test_saml_request_exceptions(self, mocked_get):

    self.__create_saml_configurations__()
    mocked_get.side_effect = exceptions.SSLError
    expected = '\nDone.\n1    provider(s)    found    in    database.\n0    skipped    and    1    attempted.\n0    updated    and    1    failed.\n'
    with self.assertRaisesRegexp(CommandError, 'SSLError:'):
        call_command('saml', pull=True, stdout=self.stdout)
    self.assertIn(expected, self.stdout.getvalue())
    mocked_get.side_effect = exceptions.ConnectionError
    with self.assertRaisesRegexp(CommandError, 'ConnectionError:'):
        call_command('saml', pull=True, stdout=self.stdout)
    self.assertIn(expected, self.stdout.getvalue())
    mocked_get.side_effect = exceptions.HTTPError
    with self.assertRaisesRegexp(CommandError, 'HTTPError:'):
        call_command('saml', pull=True, stdout=self.stdout)
    self.assertIn(expected, self.stdout.getvalue())
