def test_writebulkjob(mock_dump): """ ensure job def calls json.dump """ bulk = Bulk(test=True) bulk.job = JOB_EXPORTS_CONTACTS mock_dump.return_value = None bulk.write_job('/tmp/pyeloqua_test_bulk_write.json') assert mock_dump.called
def test_readbulkjob(): """ import correctly sets Bulk.job """ bulk1 = Bulk(test=True) bulk1.job = JOB_EXPORTS_CONTACTS bulk1.write_job('/tmp/pyeloqua_test_bulk_write.json') bulk2 = Bulk(test=True) bulk2.read_job('/tmp/pyeloqua_test_bulk_write.json') assert bulk2.job == bulk1.job
def test_create_imports_error(mock_post): """ raise exception on bad import def """ bulk = Bulk(test=True) bulk.job = JOB_IMPORTS_CONTACTS_BAD mock_post.return_value = Mock(ok=True, status_code=400) mock_post.return_value.json.return_value = deepcopy( IMPORT_JOB_RESPONSE_BAD) bulk.create_def('test name')
def test_create_imports_setdef(mock_post): """ set job_def for create import """ bulk = Bulk(test=True) bulk.job = JOB_IMPORTS_CONTACTS mock_post.return_value = Mock(ok=True, status_code=201) mock_post.return_value.json.return_value = deepcopy(IMPORT_JOB_RESPONSE) bulk.create_def('test name') assert bulk.job_def == IMPORT_JOB_RESPONSE
def test_create_imports_call(mock_post): """ api call for create import """ bulk = Bulk(test=True) bulk.job = JOB_IMPORTS_CONTACTS mock_post.return_value = Mock(ok=True, status_code=201) mock_post.return_value.json.return_value = deepcopy(IMPORT_JOB_RESPONSE) bulk.create_def('test name') url = bulk.bulk_base + '/contacts/imports' mock_post.assert_called_with(url=url, auth=bulk.auth, data=DATA_IMPORTS_CONTACTS, headers=POST_HEADERS)
def test_create_exports_call_sgfilt(mock_post): """ api call for create export - single filter """ bulk = Bulk(test=True) bulk.job = JOB_EXPORTS_CONTACTS_F1 mock_post.return_value = Mock(ok=True, status_code=201) mock_post.return_value.json.return_value = deepcopy(EXPORT_JOB_RESPONSE) bulk.create_def('test name') url = bulk.bulk_base + '/contacts/exports' mock_post.assert_called_with(url=url, auth=bulk.auth, data=DATA_EXPORTS_CONTACTS_F1, headers=POST_HEADERS)