コード例 #1
0
def test_record_thrift_exception(tmpdir, mock_server, thrift_service):
    path = tmpdir.join('data.yaml')

    myservice = thrift_request_builder(
        'myservice', thrift_service, hostport=mock_server.hostport
    )

    mock_server.expect_call(thrift_service, method='getItem').and_raise(
        thrift_service.ItemDoesNotExist('foo')
    ).once()

    client = TChannel('test')

    with vcr.use_cassette(str(path)) as cass:
        with pytest.raises(thrift_service.ItemDoesNotExist):
            client.thrift(myservice.getItem('foo')).result(1)

    assert cass.play_count == 0
    assert path.check(file=True)

    with vcr.use_cassette(str(path)) as cass:
        with pytest.raises(thrift_service.ItemDoesNotExist):
            client.thrift(myservice.getItem('foo')).result(1)

    assert cass.play_count == 1
コード例 #2
0
def test_record_success_thrift(tmpdir, thrift_service, mock_server):
    myservice = thrift_request_builder('myservice',
                                       thrift_service,
                                       hostport=mock_server.hostport)

    path = tmpdir.join('data.yaml')
    expected_item = thrift_service.Item(
        'foo', thrift_service.Value(stringValue='bar'))
    mock_server.expect_call(thrift_service,
                            method='getItem').and_result(expected_item).once()

    client = TChannel('test')

    with vcr.use_cassette(str(path)) as cass:
        response = client.thrift(myservice.getItem('foo')).result(1)
        item = response.body
        assert item == expected_item

    assert cass.play_count == 0
    assert path.check(file=True)

    with vcr.use_cassette(str(path)) as cass:
        response = client.thrift(myservice.getItem('foo')).result(1)
        item = response.body
        assert item == expected_item

    assert cass.play_count == 1
コード例 #3
0
def test_record_success_thrift(tmpdir, thrift_service, mock_server):
    myservice = thrift_request_builder(
        'myservice', thrift_service, hostport=mock_server.hostport
    )

    path = tmpdir.join('data.yaml')
    expected_item = thrift_service.Item(
        'foo', thrift_service.Value(stringValue='bar')
    )
    mock_server.expect_call(thrift_service, method='getItem').and_result(
        expected_item
    ).once()

    client = TChannel('test')

    with vcr.use_cassette(str(path)) as cass:
        response = client.thrift(myservice.getItem('foo')).result(1)
        item = response.body
        assert item == expected_item

    assert cass.play_count == 0
    assert path.check(file=True)

    with vcr.use_cassette(str(path)) as cass:
        response = client.thrift(myservice.getItem('foo')).result(1)
        item = response.body
        assert item == expected_item

    assert cass.play_count == 1
コード例 #4
0
def test_call(mock_server, thrift_service):

    expected = thrift_service.Item(
        key='foo', value=thrift_service.Value(integerValue=42)
    )

    mock_server.expect_call(
        thrift_service,
        'thrift',
        method='getItem',
    ).and_result(expected)

    thrift_service = thrift_request_builder(
        service='thrift-service',
        thrift_module=thrift_service,
        hostport=mock_server.hostport,
    )

    tchannel = TChannel('test-client')

    future = tchannel.thrift(
        thrift_service.getItem('foo')
    )
    result = future.result()

    assert expected == result.body
コード例 #5
0
def test_call(mock_server, thrift_service):

    expected = thrift_service.Item(key="foo", value=thrift_service.Value(integerValue=42))

    mock_server.expect_call(thrift_service, "thrift", method="getItem").and_result(expected)

    thrift_service = thrift_request_builder(
        service="thrift-service", thrift_module=thrift_service, hostport=mock_server.hostport
    )

    tchannel = TChannel("test-client")

    future = tchannel.thrift(thrift_service.getItem("foo"))
    result = future.result()

    assert expected == result.body
コード例 #6
0
def test_call(mock_server, thrift_service):

    expected = thrift_service.Item(key='foo',
                                   value=thrift_service.Value(integerValue=42))

    mock_server.expect_call(
        thrift_service,
        'thrift',
        method='getItem',
    ).and_result(expected)

    thrift_service = thrift_request_builder(
        service='thrift-service',
        thrift_module=thrift_service,
        hostport=mock_server.hostport,
    )

    tchannel = TChannel('test-client')

    future = tchannel.thrift(thrift_service.getItem('foo'))
    result = future.result()

    assert expected == result.body
コード例 #7
0
    # notification and tracking tags
    notification_tracking_tag = 'latam_fraud_fasttrack_soft_tag'
    waitlist_tracking_tag = 'latam_fraud_fasttrack_wl_queue'

    #tag and add notes
    tag_notes_courier(all_results)

    col_report_id = 'e5kwFFUNB'  # cool off logic
    col_results = co_engine(df, col_report_id, query_datestr)
    update_status(col_results, 'Cool off logic: %s' % col_report_id, nowstr)
    #add cooloff output to all_results after tagging and actioning
    if col_results is not None:
        for row in col_results:
            tchannel.thrift(
                populous_service.UserService.createUserTag(
                    row['driver_uuid'], row['tag']))
            row['Status'] = "Actioned"
        all_results += col_results

    # if output from all queries is null
    if all_results:
        df_f = pd.DataFrame(all_results)
        df_f['timestamp'] = nowstr
    else:
        df_f = pd.DataFrame()
        df_f['Status'] = ''
        df_f['city_id'] = ''
        df_f['driver_uuid'] = ''
        df_f['note'] = ''
        df_f['tag'] = ''