def test_execute_loads_high_volume_records(self): connection = MockConnection(bulk_insert_results=[ UploadResult("001000000{:06d}".format(i + 1), True, True, "") for i in range(20000) ]) op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id = Mock() record_list = [{ "Id": "001000000{:06d}".format(i), "Name": "Account {:06d}".format(i) } for i in range(20000)] op.file_store.records["Account"] = record_list op.get_result_file = Mock() load_step = amaxa.LoadStep("Account", ["Name"]) op.add_step(load_step) load_step.initialize() load_step.execute() self.assertEqual(20000, op.register_new_id.call_count) # Validate that the correct Ids were mapped # Each Id should be mapped to itself plus one. for index, each_call in enumerate(op.register_new_id.call_args_list): self.assertEqual( unittest.mock.call( "Account", amaxa.SalesforceId("001000000{:06d}".format(index)), amaxa.SalesforceId("001000000{:06d}".format(index + 1)), ), each_call, )
def test_transform_records_runs_transform_before_cleaning(self): connection = Mock() op = amaxa.LoadOperation(connection) op.mappers["Account"] = Mock() op.mappers["Account"].transform_record = Mock(return_value={ "Name": "Test2", "ParentId": "001000000000001", "Excess__c": True, }) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) load_step.dependent_lookups = set() load_step.self_lookups = set() self.assertEqual( { "Name": "Test2", "ParentId": "001000000000001" }, load_step.transform_record({ "Account Name": "Test2", "ParentId": "001000000000001", "Excess__c": True, }), )
def test_loads_and_extracts_high_data_volume(self): # This is a single unit test rather than multiple to save on execution time. records = [] for i in range(100000): records.append({ "Id": "00Q000000{:06d}".format(i), "Company": "[not provided]", "LastName": "Lead {:06d}".format(i), }) op = amaxa.LoadOperation(Connection(self.connection, "52.0")) op.file_store = MockFileStore() op.file_store.records["Lead"] = records op.add_step(amaxa.LoadStep("Lead", set(["LastName", "Company"]))) op.initialize() op.execute() self.assertEqual( 100000, self.connection.query("SELECT count() FROM Lead").get("totalSize")) oc = amaxa.ExtractOperation(Connection(self.connection, "52.0")) oc.file_store = MockFileStore() extraction = amaxa.ExtractionStep("Lead", amaxa.ExtractionScope.ALL_RECORDS, ["Id", "LastName"]) oc.add_step(extraction) extraction.initialize() extraction.execute() self.assertEqual(100000, len(oc.get_extracted_ids("Lead")))
def test_execute_dependent_updates_handles_exceptions__outside_lookups(self): record_list = [ {"Name": "Test", "Id": "001000000000000", "ParentId": ""}, {"Name": "Test 2", "Id": "001000000000001", "ParentId": "001000000000002"}, ] connection = MockConnection() op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.file_store.records["Account"] = record_list op.register_new_id = Mock() op.register_error = Mock() load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) load_step.set_lookup_behavior_for_field( "ParentId", amaxa.OutsideLookupBehavior.ERROR ) op.add_step(load_step) load_step.initialize() load_step.execute_dependent_updates() self.assertEqual( [ unittest.mock.call( "Account", record_list[1]["Id"], f"Account {record_list[1]['Id']} has an outside reference in field ParentId (001000000000002), which is not allowed by the extraction configuration.", ), ], op.register_error.call_args_list, )
def test_execute_handles_exceptions__bad_data(self): record_list = [ {"Name": "Test", "Id": "001000000000000", "IsDeleted": "false"}, {"Name": "Test 2", "Id": "001000000000001", "IsDeleted": "foo"}, ] connection = MockConnection() op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.file_store.records["Account"] = record_list op.register_new_id = Mock() op.register_error = Mock() load_step = amaxa.LoadStep("Account", ["Name", "IsDeleted"]) op.add_step(load_step) load_step.initialize() load_step.execute() self.assertEqual( [ unittest.mock.call( "Account", record_list[1]["Id"], f"Bad data in record {record_list[1]['Id']}: Invalid Boolean value foo", ), ], op.register_error.call_args_list, )
def test_execute_does_not_insert_records_prepopulated_in_id_map(self): record_list = [ { "Name": "Test", "Id": "001000000000000" }, { "Name": "Test 2", "Id": "001000000000001" }, { "Name": "Test 3", "Id": "001000000000002" }, ] clean_record_list = [{"Name": "Test 2"}, {"Name": "Test 3"}] connection = MockConnection(bulk_insert_results=[ UploadResult("001000000000007", True, True, ""), UploadResult("001000000000008", True, True, ""), ]) op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000005"), ) op.register_new_id = Mock() op.file_store.records["Account"] = record_list op.mappers["Account"] = Mock() op.mappers["Account"].transform_record = Mock(side_effect=lambda x: x) load_step = amaxa.LoadStep("Account", ["Name"]) op.add_step(load_step) load_step.primitivize = Mock(side_effect=lambda x: x) load_step.populate_lookups = Mock(side_effect=lambda x, y, z: x) load_step.initialize() load_step.execute() op.connection.bulk_api_insert.assert_called_once_with( "Account", clean_record_list, load_step.get_option("bulk-api-timeout"), load_step.get_option("bulk-api-poll-interval"), load_step.get_option("bulk-api-batch-size"), ) op.register_new_id.assert_has_calls([ unittest.mock.call( "Account", amaxa.SalesforceId("001000000000001"), amaxa.SalesforceId("001000000000007"), ), unittest.mock.call( "Account", amaxa.SalesforceId("001000000000002"), amaxa.SalesforceId("001000000000008"), ), ])
def test_transform_records_calls_context_mapper(self): connection = Mock() op = amaxa.LoadOperation(connection) op.mappers["Account"] = Mock() op.mappers["Account"].transform_record = Mock( return_value={ "Name": "Test2", "ParentId": "001000000000001" }) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) load_step.dependent_lookups = set() load_step.self_lookups = set() self.assertEqual( { "Name": "Test2", "ParentId": "001000000000001" }, load_step.transform_record({ "Name": "Test1", "ParentId": "001000000000000" }), ) op.mappers["Account"].transform_record.assert_called_once_with({ "Name": "Test1", "ParentId": "001000000000000" })
def test_LoadOperationLoader_validates_file_against_field_group_matching( self): ex = { "version": 1, "operation": [{ "sobject": "Account", "field-group": "smart", "extract": { "all": True } }], } context_fieldnames = (amaxa.LoadOperation( MockConnection()).get_filtered_field_map( "Account", lambda f: f["createable"] and f["type"] not in ["location", "address", "base64"], ).keys()) fieldnames = context_fieldnames self._run_success_test( ex, input_data={ "Account.csv": ",".join(fieldnames), "Account-results.csv": "" }, )
def test_execute_dependent_updates_handles_errors(self): record_list = [ { "Name": "Test", "Id": "001000000000000", "ParentId": "001000000000001" }, { "Name": "Test 2", "Id": "001000000000001", "ParentId": "001000000000000" }, ] error = [{ "statusCode": "DUPLICATES_DETECTED", "message": "There are duplicates", "fields": [], "extendedErrorDetails": None, }] connection = MockConnection(bulk_update_results=[ UploadResult(None, False, False, error), UploadResult(None, False, False, error), ]) op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000002"), ) op.register_new_id( "Account", amaxa.SalesforceId("001000000000001"), amaxa.SalesforceId("001000000000003"), ) op.register_new_id = Mock() op.register_error = Mock() op.file_store.records["Account"] = record_list load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) load_step.initialize() load_step.execute_dependent_updates() self.assertEqual( [ unittest.mock.call("Account", record_list[0]["Id"], load_step.format_error(error)), unittest.mock.call("Account", record_list[1]["Id"], load_step.format_error(error)), ], op.register_error.call_args_list, )
def test_get_value_for_lookup_with_blank_input(self): connection = Mock() op = amaxa.LoadOperation(connection) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) self.assertEqual( load_step.get_value_for_lookup("ParentId", "", "001000000000002"), "")
def test_execute_dependent_updates_uses_bulk_api_options(self): record_list = [ {"Name": "Test", "Id": "001000000000000", "ParentId": "001000000000001"}, {"Name": "Test 2", "Id": "001000000000001", "ParentId": "001000000000000"}, ] cleaned_record_list = [ {"Id": "001000000000002AAA", "ParentId": "001000000000003AAA"}, {"Id": "001000000000003AAA", "ParentId": "001000000000002AAA"}, ] connection = MockConnection( bulk_update_results=[ UploadResult("001000000000002", True, True, ""), UploadResult("001000000000003", True, True, ""), ] ) op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000002"), ) op.register_new_id( "Account", amaxa.SalesforceId("001000000000001"), amaxa.SalesforceId("001000000000003"), ) op.register_new_id = Mock() op.register_error = Mock() op.file_store.records["Account"] = record_list load_step = amaxa.LoadStep( "Account", ["Name", "ParentId"], options={ "bulk-api-poll-interval": 10, "bulk-api-timeout": 600, "bulk-api-batch-size": 5000, "bulk-api-mode": "Serial", }, ) op.add_step(load_step) load_step.initialize() load_step.execute_dependent_updates() op.connection.bulk_api_update.assert_called_once_with( "Account", cleaned_record_list, 600, 10, 5000, "Serial" )
def test_validate_field_permissions_flags_fields(self): context = core.OperationLoader({}, None, InputType.LOAD_OPERATION) context.result = amaxa.LoadOperation(MockConnection()) context.result.steps = [Mock()] context.result.steps[0].sobjectname = "Account" context.result.steps[0].field_scope = set(["Name", "IsDeleted"]) context._validate_field_permissions("createable") self.assertEqual( [ "Field Account.IsDeleted does not exist or does not have the correct CRUD permission (createable)." ], context.errors, )
def test_get_value_for_lookup_with_drop_behavior(self): connection = Mock() op = amaxa.LoadOperation(connection) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) load_step.set_lookup_behavior_for_field( "ParentId", amaxa.OutsideLookupBehavior.DROP_FIELD) self.assertEqual( load_step.get_value_for_lookup("ParentId", "001000000000000", "001000000000002"), "", )
def test_transform_records_cleans_excess_fields(self): connection = Mock() op = amaxa.LoadOperation(connection) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) load_step.dependent_lookups = set() load_step.self_lookups = set() self.assertEqual( {"Name": "Test2", "ParentId": "001000000000001"}, load_step.transform_record( {"Name": "Test2", "ParentId": "001000000000001", "Excess__c": True} ), )
def test_maps_record_ids(self): connection = Mock() op = amaxa.LoadOperation(connection) op.file_store = MockFileStore() op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000001"), ) self.assertEqual( amaxa.SalesforceId("001000000000001"), op.get_new_id(amaxa.SalesforceId("001000000000000")), )
def test_converts_data_for_bulk_api__failures(self): connection = Mock() op = amaxa.LoadOperation(connection) op.get_field_map = Mock( return_value={ "Boolean__c": {"soapType": "xsd:boolean"}, "Address__c": {"soapType": "xsd:address"}, } ) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) with pytest.raises(ValueError): load_step.primitivize({"Boolean__c": "blah"}) assert load_step.primitivize({"Address__c": "foo"})["Address__c"] is None
def test_converts_data_for_bulk_api(self): connection = Mock() op = amaxa.LoadOperation(connection) op.get_field_map = Mock( return_value={ "Name": {"soapType": "xsd:string"}, "Boolean__c": {"soapType": "xsd:boolean"}, "Boolean_False__c": {"soapType": "xsd:boolean"}, "Id": {"soapType": "tns:ID"}, "Date__c": {"soapType": "xsd:date"}, "DateTime__c": {"soapType": "xsd:dateTime"}, "Int__c": {"soapType": "xsd:int"}, "Double__c": {"soapType": "xsd:double"}, "Random__c": {"soapType": "xsd:string"}, } ) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) record = { "Name": "Test", "Boolean__c": "yes", "Boolean_False__c": "no", "Id": "001000000000001", "Date__c": "2018-12-31", "DateTime__c": "2018-12-31T00:00:00.000Z", "Int__c": "100", "Double__c": "10.1", "Random__c": "", } self.assertEqual( { "Name": "Test", "Boolean__c": "true", "Boolean_False__c": "false", "Id": "001000000000001", "Date__c": "2018-12-31", "DateTime__c": "2018-12-31T00:00:00.000Z", "Int__c": "100", "Double__c": "10.1", "Random__c": None, }, load_step.primitivize(record), )
def test_loads_single_object(self): records = [ { "Id": "01t000000000001", "Name": "Tauron Taffy", "IsActive": "True", "ProductCode": "TAFFY_TAUR", }, { "Id": "01t000000000002", "Name": "Gemenese Goulash", "IsActive": "True", "ProductCode": "GLSH", }, { "Id": "01t000000000003AAA", "Name": "Caprica Corn", "IsActive": "False", "ProductCode": "CPRCC", }, ] op = amaxa.LoadOperation(Connection(self.connection)) op.file_store = MockFileStore() op.file_store.records["Product2"] = records op.add_step( amaxa.LoadStep( "Product2", set(["Name", "IsActive", "ProductCode", "Description"]) ) ) op.initialize() op.execute() loaded_products = self.connection.query_all( "SELECT Id, Name, IsActive, ProductCode FROM Product2" ).get("records") self.assertEqual(3, len(loaded_products)) required_names = {x["Name"] for x in records} for r in loaded_products: self.register_case_record("Product2", r["Id"]) self.assertIn(r["Name"], required_names) required_names.remove(r["Name"]) self.assertEqual(0, len(required_names))
def test_execute_runs_all_passes(self): connection = Mock() first_step = Mock(sobjectname="Account") second_step = Mock(sobjectname="Contact") op = amaxa.LoadOperation(connection) op.file_store = MockFileStore() op.add_step(first_step) op.add_step(second_step) self.assertEqual(0, op.execute()) first_step.execute.assert_called_once_with() first_step.execute_dependent_updates.assert_called_once_with() second_step.execute.assert_called_once_with() second_step.execute_dependent_updates.assert_called_once_with()
def test_get_value_for_lookup_with_parent_available(self): connection = Mock() op = amaxa.LoadOperation(connection) op.file_store = Mock() op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000001"), ) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) self.assertEqual( load_step.get_value_for_lookup("ParentId", "001000000000000", "001000000000002"), str(amaxa.SalesforceId("001000000000001")), )
def test_register_error_logs_to_result_file(self): connection = Mock() first_step = Mock() first_step.sobjectname = "Account" op = amaxa.LoadOperation(connection) op.file_store = MockFileStore() op.add_step(first_step) first_step.execute.side_effect = lambda: op.register_error( "Account", "001000000000000", "err" ) self.assertEqual(-1, op.execute()) op.file_store.get_csv( "Account", amaxa.FileType.RESULT ).writerow.assert_called_once_with( {constants.ORIGINAL_ID: "001000000000000", constants.ERROR: "err"} )
def test_register_new_id_writes_result_entries(self): connection = Mock() op = amaxa.LoadOperation(connection) op.file_store = MockFileStore() op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000001"), ) op.file_store.get_csv( "Account", amaxa.FileType.RESULT ).writerow.assert_called_once_with( { constants.ORIGINAL_ID: str(amaxa.SalesforceId("001000000000000")), constants.NEW_ID: str(amaxa.SalesforceId("001000000000001")), } )
def test_get_value_for_lookup_with_error_behavior(self): connection = Mock() op = amaxa.LoadOperation(connection) load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) load_step.set_lookup_behavior_for_field( "ParentId", amaxa.OutsideLookupBehavior.ERROR) with self.assertRaises( amaxa.AmaxaException, msg="{} {} has an outside reference in field {} ({}), " "which is not allowed by the extraction configuration.".format( "Account", "001000000000002", "ParentId", "001000000000000"), ): load_step.get_value_for_lookup("ParentId", "001000000000000", "001000000000002")
def test_execute_resumes_with_dependent_updates_if_stage_set(self): connection = Mock() first_step = Mock(sobjectname="Account") second_step = Mock(sobjectname="Contact") op = amaxa.LoadOperation(connection) op.file_store = MockFileStore() op.stage = amaxa.LoadStage.DEPENDENTS op.add_step(first_step) op.add_step(second_step) self.assertEqual(0, op.execute()) first_step.execute.assert_not_called() second_step.execute.assert_not_called() first_step.execute_dependent_updates.assert_called_once_with() second_step.execute_dependent_updates.assert_called_once_with()
def test_execute_does_not_run_bulk_job_if_all_records_inserted(self): record_list = [{"Name": "Test", "Id": "001000000000000"}] connection = MockConnection() op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000005"), ) op.register_new_id = Mock() op.file_store.records["Account"] = record_list load_step = amaxa.LoadStep("Account", ["Name"]) op.add_step(load_step) load_step.initialize() load_step.execute() op.connection.bulk_api_insert.assert_not_called()
def test_execute_stops_after_first_error_in_step_execute_dependent_updates(self): connection = Mock() op = amaxa.LoadOperation(connection) op.file_store = MockFileStore() first_step = Mock(sobjectname="Account") second_step = Mock(sobjectname="Contact") first_step.execute_dependent_updates.side_effect = lambda: op.register_error( "Account", "001000000000000", "err" ) op.add_step(first_step) op.add_step(second_step) self.assertEqual(-1, op.execute()) first_step.execute.assert_called_once_with() first_step.execute_dependent_updates.assert_called_once_with() second_step.execute.assert_called_once_with() second_step.execute_dependent_updates.assert_not_called()
def test_execute_uses_custom_bulk_api_options(self): record_list = [ { "Name": "Test", "Id": "001000000000000" }, { "Name": "Test 2", "Id": "001000000000001" }, ] cleaned_record_list = [{"Name": "Test"}, {"Name": "Test 2"}] connection = MockConnection(bulk_insert_results=[ UploadResult("001000000000002", True, True, ""), UploadResult("001000000000003", True, True, ""), ]) op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id = Mock() op.file_store.records["Account"] = record_list step = amaxa.LoadStep( "Account", ["Name"], options={ "bulk-api-poll-interval": 10, "bulk-api-timeout": 600, "bulk-api-batch-size": 5000, "bulk-api-mode": "Serial", }, ) step.context = op step.primitivize = Mock(side_effect=lambda x: x) step.populate_lookups = Mock(side_effect=lambda x, y, z: x) step.initialize() step.execute() op.connection.bulk_api_insert.assert_called_once_with( "Account", cleaned_record_list, 600, 10, 5000, "Serial")
def test_LoadOperationLoader_validates_file_against_field_group_with_strict(self): ex = { "version": 1, "operation": [ { "sobject": "Account", "field-group": "writeable", "extract": {"all": True}, "input-validation": "strict", } ], } fieldnames = ["Id", "Name"] context_fieldnames = ( amaxa.LoadOperation(MockConnection()) .get_filtered_field_map( "Account", lambda f: f["createable"] and f["type"] not in ["location", "address", "base64"], ) .keys() ) self._run_error_validating_test( ex, [ "Input file for sObject {} does not match specified field scope.\nScope: {}\nFile Columns: {}\n".format( "Account", ", ".join(sorted(context_fieldnames)), ", ".join(sorted(set(fieldnames) - set(["Id"]))), ) ], input_data={ "Account.csv": ",".join(fieldnames) + "\n", "Account-results.csv": "", }, )
def test_execute_dependent_updates_handles_lookups(self): record_list = [ { "Name": "Test", "Id": "001000000000000", "ParentId": "001000000000004" }, { "Name": "Test 2", "Id": "001000000000001", "ParentId": "001000000000005" }, ] transformed_record_list = [ { "Id": str(amaxa.SalesforceId("001000000000002")), "ParentId": str(amaxa.SalesforceId("001000000000006")), }, { "Id": str(amaxa.SalesforceId("001000000000003")), "ParentId": str(amaxa.SalesforceId("001000000000007")), }, ] connection = MockConnection(bulk_update_results=[ UploadResult("001000000000002", True, True, ""), UploadResult("001000000000003", True, True, ""), ]) op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id( "Account", amaxa.SalesforceId("001000000000004"), amaxa.SalesforceId("001000000000006"), ) op.register_new_id( "Account", amaxa.SalesforceId("001000000000005"), amaxa.SalesforceId("001000000000007"), ) op.register_new_id( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000002"), ) op.register_new_id( "Account", amaxa.SalesforceId("001000000000001"), amaxa.SalesforceId("001000000000003"), ) op.register_new_id = Mock() op.register_error = Mock() op.file_store.records["Account"] = record_list load_step = amaxa.LoadStep("Account", ["Name", "ParentId"]) op.add_step(load_step) load_step.initialize() load_step.execute_dependent_updates() op.register_error.assert_not_called() op.connection.bulk_api_update.assert_called_once_with( "Account", transformed_record_list, load_step.get_option("bulk-api-timeout"), load_step.get_option("bulk-api-poll-interval"), load_step.get_option("bulk-api-batch-size"), )
def test_execute_transforms_and_loads_records_with_lookups(self): record_list = [ { "Name": "Test", "Id": "001000000000000", "OwnerId": "500000000000000" }, { "Name": "Test 2", "Id": "001000000000001", "OwnerId": "500000000000001" }, ] transformed_record_list = [ { "Name": "Test", "OwnerId": str(amaxa.SalesforceId("500000000000002")) }, { "Name": "Test 2", "OwnerId": str(amaxa.SalesforceId("500000000000003")) }, ] connection = MockConnection(bulk_insert_results=[ UploadResult("001000000000002", True, True, ""), UploadResult("001000000000003", True, True, ""), ]) op = amaxa.LoadOperation(Mock(wraps=connection)) op.file_store = MockFileStore() op.register_new_id( "User", amaxa.SalesforceId("500000000000000"), amaxa.SalesforceId("500000000000002"), ) op.register_new_id( "User", amaxa.SalesforceId("500000000000001"), amaxa.SalesforceId("500000000000003"), ) op.register_new_id = Mock() op.file_store.records["Account"] = record_list op.mappers["Account"] = Mock() op.mappers["Account"].transform_record = Mock(side_effect=lambda x: x) load_step = amaxa.LoadStep("Account", ["Name", "OwnerId"]) op.add_step(load_step) load_step.primitivize = Mock(side_effect=lambda x: x) load_step.initialize() load_step.descendent_lookups = set(["OwnerId"]) load_step.execute() op.mappers["Account"].transform_record.assert_has_calls( [unittest.mock.call(x) for x in record_list]) load_step.primitivize.assert_has_calls( [unittest.mock.call(x) for x in transformed_record_list]) op.connection.bulk_api_insert.assert_called_once_with( "Account", transformed_record_list, load_step.get_option("bulk-api-timeout"), load_step.get_option("bulk-api-poll-interval"), load_step.get_option("bulk-api-batch-size"), ) op.register_new_id.assert_has_calls([ unittest.mock.call( "Account", amaxa.SalesforceId("001000000000000"), amaxa.SalesforceId("001000000000002"), ), unittest.mock.call( "Account", amaxa.SalesforceId("001000000000001"), amaxa.SalesforceId("001000000000003"), ), ])