コード例 #1
0
def test_mocked_merge_error(m):
    datadir = tempfile.mkdtemp()
    setdatadir(datadir)
    mock_oauth(m)
    mock_login(m)

    # test bigger part of merge flow but don't check output
    m.post(url='https://fake-host.salesforce.com/services/Soap/c/37.0',
           text=MERGE_HTTP_FAULT_RESP,
           status_code=201)
    with open(os.path.join(datadir, 'mergedata.csv'), 'w') as mergedata_f:
        csv_writer = CsvWriter(mergedata_f, False)
        csv_writer.write_csv([BULK_DATA_IN.fields])
        csv_writer.write_csv(BULK_DATA_IN.rows)

    config_filename = 'test-config.ini'
    endpoint_names = {'dst': 'test', 'src': 'test'}
    with open(config_filename) as config_f:
        with open('tests/sql/merge.sql') as job_f:
            try:
                run_job_from_file(config_f, job_f, endpoint_names, {}, False,
                                  False)
                # expected to fail
                assert (0)
            except SoapException:
                pass
コード例 #2
0
def test_empty_query_res(mock_docall, m):
    # mock setup    
    mock_oauth(m)
    mock_login(m)
    sf_bulk_connector.JOB_CHECK_TIMER = 0
    mockers.mock_empty_query_res(mock_docall, m)
    
    setdatadir(tempfile.mkdtemp())
    with open(config_file) as conf_file:
        with open('tests/sql/empty_query_res.sql') as job_file:
            run_job_from_file(conf_file, job_file,
                              {'src':'test', 'dst':'test'}, {}, None, None)
コード例 #3
0
def test_merge_bad_ascii_error(m):
    mock_oauth(m)
    mock_login(m)
    setdatadir(tempfile.mkdtemp())
    with open(config_file) as conf_file:
        with open('tests/sql/merge_bad_ascii.sql') as job_file:
            try:
                run_job_from_file(conf_file, job_file,
                                  {'src':'test', 'dst':'test'}, {}, None, None)
                # it should fail
                assert(0)
            except UnicodeEncodeError:
                pass 
コード例 #4
0
def test_merge_required_columns_error(m):
    mock_oauth(m)
    mock_login(m)
    setdatadir(tempfile.mkdtemp())
    with open(config_file) as conf_file:
        with open('tests/sql/merge_required_columns_error.sql') as job_file:
            try:
                run_job_from_file(conf_file, job_file,
                                  {'src':'test', 'dst':'test'}, {}, None, None)
                # it should fail
                assert(0)
            except SystemExit:
                pass 
コード例 #5
0
def test_upsert_unsupported(m):
    mock_oauth(m)
    mock_login(m)
    setdatadir(tempfile.mkdtemp())
    with open(config_file) as conf_file:
        with open('tests/sql/upsert_unsupported.sql') as job_file:
            try:
                run_job_from_file(conf_file, job_file,
                                  {'src':'test', 'dst':'test'}, {}, None, None)
                # it should fail
                assert(0)
            except SystemExit:
                pass
コード例 #6
0
def test_delete_syntax(m):
    # this delete operation should fail anyway but improves coverage
    mock_oauth(m)
    mock_login(m)
    setdatadir(tempfile.mkdtemp())
    with open(config_file) as conf_file:
        with open('tests/sql/delete_fake.sql') as job_file:
            try:
                run_job_from_file(conf_file, job_file,
                                  {'src':'test', 'dst':'test'}, {}, None, None)
                # it should fail
                assert(0)
            except:
                pass