Ejemplo n.º 1
0
def test_create_account_connect_parent_external_uid(
    fs,
    customers_workbook,
    mocked_responses,
    mocked_reseller,
):
    customers_workbook['Customers']['D3'] = 'create'
    customers_workbook['Customers']['A3'] = None
    customers_workbook['Customers']['C3'] = None
    customers_workbook['Customers']['F3'] = 'external_uid'
    customers_workbook.save(f'{fs.root_path}/test.xlsx')
    client = get_client()

    mocked_responses.add(
        method='GET',
        url=
        f'https://localhost/public/v1/tier/accounts?eq(external_uid,{mocked_reseller["id"]})&limit=0&offset=0',
        json=[mocked_reseller],
        headers={
            'Content-Range': 'items 0-1/1',
        },
    )
    mocked_responses.add(
        method='GET',
        url=
        f'https://localhost/public/v1/tier/accounts?eq(external_uid,{mocked_reseller["id"]})&limit=1&offset=0',
        json=[mocked_reseller],
        headers={
            'Content-Range': 'items 0-1/1',
        },
    )
    mocked_responses.add(
        method='POST',
        url='https://localhost/public/v1/tier/accounts',
        json=mocked_reseller,
    )
    synchronizer = CustomerSynchronizer(
        account_id='VA-123',
        client=client,
        silent=True,
    )
    synchronizer.open(f'{fs.root_path}/test.xlsx', 'Customers')
    synchronizer.sync()
    assert synchronizer.stats._created == 1
Ejemplo n.º 2
0
def test_sync_all_skip(fs, customers_workbook):
    customers_workbook.save(f'{fs.root_path}/test.xlsx')
    client = get_client()

    synchronizer = CustomerSynchronizer(
        account_id='VA-123',
        client=client,
        silent=True,
    )
    synchronizer.open(f'{fs.root_path}/test.xlsx', 'Customers')
    synchronizer.sync()
    assert synchronizer.stats.get_counts_as_dict() == {
        'processed': 2,
        'created': 0,
        'updated': 0,
        'deleted': 0,
        'skipped': 2,
        'errors': 0,
    }
Ejemplo n.º 3
0
def test_update_customer_no_account_connect(fs, customers_workbook,
                                            mocked_responses):
    customers_workbook['Customers']['D2'] = 'update'
    customers_workbook.save(f'{fs.root_path}/test.xlsx')
    client = get_client()

    mocked_responses.add(
        method='GET',
        url='https://localhost/public/v1/tier/accounts/TA-7374-0753-1907',
        status=404,
    )
    synchronizer = CustomerSynchronizer(
        account_id='VA-123',
        client=client,
        silent=True,
    )
    synchronizer.open(f'{fs.root_path}/test.xlsx', 'Customers')
    skipped, created, updated, errors = synchronizer.sync()
    assert errors == {2: ['Account with id TA-7374-0753-1907 does not exist']}
Ejemplo n.º 4
0
def test_create_account_connect(fs, customers_workbook, mocked_responses,
                                mocked_reseller):
    customers_workbook['Customers']['D2'] = 'create'
    customers_workbook['Customers']['A2'] = None
    customers_workbook.save(f'{fs.root_path}/test.xlsx')
    client = get_client()

    mocked_responses.add(
        method='POST',
        url='https://localhost/public/v1/tier/accounts',
        json=mocked_reseller,
    )
    synchronizer = CustomerSynchronizer(
        account_id='VA-123',
        client=client,
        silent=True,
    )
    synchronizer.open(f'{fs.root_path}/test.xlsx', 'Customers')
    synchronizer.sync()
    assert synchronizer.stats._created == 1