Beispiel #1
0
def test_post_data_except_import(mock_post):
    """ post data to an export definition """
    bulk = Bulk(test=True)
    bulk.exports('contacts')
    bulk.job_def = EXPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=201)
    bulk.post_data(IMPORT_TEST_DATA)
def test_post_data_except_import(mock_post):
    """ post data to an export definition """
    bulk = Bulk(test=True)
    bulk.exports('contacts')
    bulk.job_def = EXPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=201)
    bulk.post_data(IMPORT_TEST_DATA)
Beispiel #3
0
def test_post_data_except(mock_post):
    """ post data server error """
    bulk = Bulk(test=True)
    bulk.imports('contacts')
    bulk.job_def = IMPORT_JOB_DEF
    mock_post.return_value = Mock(ok=False, status_code=400)
    mock_post.return_value.json.return_value = {}
    bulk.post_data(IMPORT_TEST_DATA)
def test_post_data_except(mock_post):
    """ post data server error """
    bulk = Bulk(test=True)
    bulk.imports('contacts')
    bulk.job_def = IMPORT_JOB_DEF
    mock_post.return_value = Mock(ok=False, status_code=400)
    mock_post.return_value.json.return_value = {}
    bulk.post_data(IMPORT_TEST_DATA)
def test_post_data_call(mock_post):
    """ post data to an import definition """
    bulk = Bulk(test=True)
    bulk.imports('contacts')
    bulk.job_def = IMPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=201)
    bulk.post_data(IMPORT_TEST_DATA)
    mock_post.assert_called_with(url=bulk.bulk_base + '/contacts/imports/1/data',
                                 auth=bulk.auth,
                                 data=dumps(IMPORT_TEST_DATA, ensure_ascii=False).encode('utf8'),
                                 headers=POST_HEADERS)
Beispiel #6
0
def test_post_data_call(mock_post):
    """ post data to an import definition """
    bulk = Bulk(test=True)
    bulk.imports('contacts')
    bulk.job_def = IMPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=201)
    bulk.post_data(IMPORT_TEST_DATA)
    mock_post.assert_called_with(url=bulk.bulk_base +
                                 '/contacts/imports/1/data',
                                 auth=bulk.auth,
                                 data=dumps(IMPORT_TEST_DATA,
                                            ensure_ascii=False).encode('utf8'),
                                 headers=POST_HEADERS)