def _run_validation_test(self, input_data): with patch("simple_salesforce.Salesforce") as sf_mock: with patch("salesforce_bulk.SalesforceBulk"): sf_mock.return_value.bulk_url = "https://salesforce.com" credential_loader = loader.CredentialLoader(input_data, "48.0") credential_loader.load() self.assertEqual([], credential_loader.errors) self.assertIsNotNone(credential_loader.result)
def _run_authentication_test(self, input_data, arguments): with patch("simple_salesforce.Salesforce") as sf_mock: with patch("salesforce_bulk.SalesforceBulk"): sf_mock.return_value.bulk_url = "https://salesforce.com" credential_loader = loader.CredentialLoader(input_data, "48.0") credential_loader.load() self.assertEqual([], credential_loader.errors) self.assertIsNotNone(credential_loader.result) sf_mock.assert_called_once_with(version="48.0", **arguments)
def _run_failure_test(self, input_data, errors): with patch("simple_salesforce.Salesforce") as sf_mock: with patch("salesforce_bulk.SalesforceBulk"): sf_mock.return_value.bulk_url = "https://salesforce.com" credential_loader = loader.CredentialLoader(input_data, "48.0") credential_loader.load() if type(errors) is list: self.assertEqual(errors, credential_loader.errors) else: self.assertEqual(errors, len(credential_loader.errors)) self.assertIsNone(credential_loader.result)
def test_load_credentials_traps_login_errors(self): credentials = loader.CredentialLoader({}, "48.0") side_effect = simple_salesforce.SalesforceError( "https://salesforce.com", 401, "describe", "") credentials.result = Mock() credentials.result.get_global_describe = Mock(side_effect=side_effect) credentials._post_validate() self.assertEqual( ["Unable to authenticate to Salesforce: {}".format(side_effect)], credentials.errors, ) self.assertIsNone(credentials.result)
def _run_authentication_test(self, input_data, arguments): with patch("simple_salesforce.Salesforce") as sf_mock: with patch("salesforce_bulk.SalesforceBulk"): sf_mock.return_value.bulk_url = "https://salesforce.com" credential_loader = loader.CredentialLoader(input_data, "52.0") credential_loader.load() self.assertEqual([], credential_loader.errors) self.assertIsNotNone(credential_loader.result) if "username" in arguments: arguments["domain"] = ( "test" if arguments.get("sandbox", False) else "login" ) if "sandbox" in arguments: del arguments["sandbox"] sf_mock.assert_called_once_with(version="52.0", **arguments)