示例#1
0
def test_rts(rts_host):

    request = req.RecsRequest(site_id='8bf9fa832a2cf351cf1a19098038459d',
                              bsin=BSIN,
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    metafilter = recs_filter.TFilter(
        existence=None,
        and_=[
            recs_filter.TFilter(existence=None,
                                and_=None,
                                or_=None,
                                recency=None,
                                overlap=None,
                                any=None,
                                named='GLOBAL',
                                range=None),
            recs_filter.TFilter(existence=None,
                                and_=None,
                                or_=None,
                                recency=recs_filter.TRecencyFilter(
                                    range=recs_filter.TRange(min_=-604800.0,
                                                             max_=None),
                                    field='pubDate'),
                                overlap=None,
                                any=None,
                                named=None,
                                range=None),
            recs_filter.TFilter(existence=None,
                                and_=None,
                                or_=None,
                                recency=None,
                                overlap=recs_filter.TOverlapFilter(
                                    amount=recs_filter.TRange(min_=1.0,
                                                              max_=None),
                                    values=['article_alist'],
                                    field='resource-type',
                                    match_type=0),
                                any=None,
                                named=None,
                                range=None)
        ],
        or_=None,
        recency=None,
        overlap=None,
        any=None,
        named=None,
        range=None)

    request.groups['articles'] = req.RecGroupRequest(count=COUNT,
                                                     metafilter=metafilter)

    config = {'host': rts_host, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT
示例#2
0
def test_rts(rts_host):
    COUNT1 = 5
    COUNT2 = 1
    request = req.RecsRequest(site_id='honest-reporting',
                              bsin='ca297fe2-7390-4a70-9778-19c63b2cb3be',
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    metafilter = recs_filter.TFilter(overlap=None,
                                     existence=None,
                                     recency=None,
                                     and_=None,
                                     range=None,
                                     or_=None,
                                     any=None,
                                     named='GLOBAL')
    request.groups['hr_all'] = req.RecGroupRequest(count=COUNT1,
                                                   metafilter=metafilter)

    metafilter = recs_filter.TFilter(
        overlap=None,
        existence=None,
        recency=None,
        and_=[
            recs_filter.TFilter(overlap=None,
                                existence=None,
                                recency=None,
                                and_=None,
                                range=None,
                                or_=None,
                                any=None,
                                named='GLOBAL'),
            recs_filter.TFilter(overlap=None,
                                existence=None,
                                recency=recs_filter.TRecencyFilter(
                                    range=recs_filter.TRange(max_=None,
                                                             min_=-172800.0),
                                    field='pubDate'),
                                and_=None,
                                range=None,
                                or_=None,
                                any=None,
                                named=None)
        ],
        range=None,
        or_=None,
        any=None,
        named=None)
    request.groups['hr_recent'] = req.RecGroupRequest(count=COUNT2,
                                                      metafilter=metafilter)

    config = {'host': rts_host, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT1 + COUNT2
示例#3
0
def test_rts(rts_host):
    request = req.RecsRequest(site_id='wide-open-eats',
                              bsin='e29221c2-e1e5-4a8e-a28d-6a2f267552c6',
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    COUNT1 = 1
    metafilter = recs_filter.TFilter(
        overlap=None,
        existence=None,
        recency=None,
        and_=[
            recs_filter.TFilter(overlap=None,
                                existence=None,
                                recency=None,
                                and_=None,
                                range=None,
                                or_=None,
                                any=None,
                                named='GLOBAL'),
            recs_filter.TFilter(overlap=None,
                                existence=None,
                                recency=recs_filter.TRecencyFilter(
                                    range=recs_filter.TRange(max_=None,
                                                             min_=-518400.0),
                                    field='pubDate'),
                                and_=None,
                                range=None,
                                or_=None,
                                any=None,
                                named=None)
        ],
        range=None,
        or_=None,
        any=None,
        named=None)
    request.groups['featured'] = req.RecGroupRequest(count=COUNT1,
                                                     metafilter=metafilter)

    COUNT2 = 15
    metafilter = recs_filter.TFilter(overlap=None,
                                     existence=None,
                                     recency=None,
                                     and_=None,
                                     range=None,
                                     or_=None,
                                     any=None,
                                     named='GLOBAL')
    request.groups['articles'] = req.RecGroupRequest(count=COUNT2,
                                                     metafilter=metafilter)

    config = {'host': rts_host, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT1 + COUNT2
示例#4
0
def test_rts(rts_host):
    request = req.RecsRequest(site_id='long-beach-post',
                              bsin='e1fb9080-f54f-47cd-923a-ae6d6d9342a0',
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    COUNT1 = 10
    metafilter = recs_filter.TFilter(
        overlap=None,
        existence=None,
        recency=None,
        and_=[
            recs_filter.TFilter(overlap=None,
                                existence=None,
                                recency=None,
                                and_=None,
                                range=None,
                                or_=None,
                                any=None,
                                named='GLOBAL'),
            recs_filter.TFilter(overlap=None,
                                existence=None,
                                recency=recs_filter.TRecencyFilter(
                                    range=recs_filter.TRange(max_=None,
                                                             min_=-86400.0),
                                    field='pubDate'),
                                and_=None,
                                range=None,
                                or_=None,
                                any=None,
                                named=None)
        ],
        range=None,
        or_=None,
        any=None,
        named=None)
    request.groups['featured'] = req.RecGroupRequest(count=COUNT1,
                                                     metafilter=metafilter)

    config = {'host': rts_host, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT1
示例#5
0
def test_rts(rts_host):
    COUNT = 3
    request = req.RecsRequest(site_id='3c499a166380645f83154eb95983ed96',
                              bsin='d3555efd-fc91-418c-a566-25c20ca31212',
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    td = timedelta(days=-2).total_seconds()
    metafilter = recs_filter.TFilter(
        overlap=None,
        recency=None,
        and_=[
            recs_filter.TFilter(overlap=None,
                                recency=None,
                                and_=None,
                                existence=None,
                                or_=None,
                                named='GLOBAL',
                                range=None),
            recs_filter.TFilter(overlap=None,
                                recency=recs_filter.TRecencyFilter(
                                    field='pubDate',
                                    range=recs_filter.TRange(min_=td,
                                                             max_=None)),
                                and_=None,
                                existence=None,
                                or_=None,
                                named=None,
                                range=None)
        ],
        existence=None,
        or_=None,
        named=None,
        range=None)

    request.groups[GROUP_NAME] = req.RecGroupRequest(count=COUNT,
                                                     metafilter=metafilter)
    config = {'host': rts_host, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT
示例#6
0
def test_rts(rts_host):
    COUNT = 4
    request = req.RecsRequest(site_id='wide-open-country',
                              bsin='47e8caf8-602f-43fd-af1a-d55f7ac1e93a',
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    td = timedelta(days=-4).total_seconds()
    metafilter = recs_filter.TFilter(overlap=None, recency=None, and_=[
        recs_filter.TFilter(overlap=None, recency=None, and_=None, existence=None, or_=None, named='GLOBAL', range=None),
        recs_filter.TFilter(overlap=None, recency=recs_filter.TRecencyFilter(field='pubDate', range=recs_filter.TRange(min_=td, max_=None)), and_=None, existence=None, or_=None, named=None, range=None)], existence=None, or_=None, named=None, range=None)

    request.groups[GROUP_NAME] = req.RecGroupRequest(count=COUNT, metafilter=metafilter)
    config = {'host': rts_host, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT
示例#7
0
def test_metafilter_resource_type_article_abs():
    COUNT = 4
    request = req.RecsRequest(site_id='cyber-creations',
                              bsin='0d53ad70-f847-425e-b09e-839a487093b3',
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    td = timedelta(days=-4).total_seconds()
    metafilter = recs_filter.TFilter(overlap=None, recency=None, and_=[
        recs_filter.TFilter(overlap=None, recency=None, and_=None, existence=None, or_=None, named='GLOBAL', range=None),
        recs_filter.TFilter(overlap=None, recency=recs_filter.TRecencyFilter(field='pubDate', range=recs_filter.TRange(min_=td, max_=None)), and_=None, existence=None, or_=None, named=None, range=None)], existence=None, or_=None, named=None, range=None)

    request.groups[GROUP_NAME] = req.RecGroupRequest(count=COUNT, metafilter=metafilter)
    config = {'host': HOST, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT
示例#8
0
def test_rts(rts_host):
    COUNT = 6
    request = req.RecsRequest(site_id='finder',
                              bsin='c5b7a9cf-7977-4da5-acaa-aa4ad3d03b69',
                              seeds=EMPTY_SEEDS,
                              excludes=EMPTY_EXCLUDES,
                              recset_id=RECSET_ID,
                              test=TEST)

    metafilter = recs_filter.TFilter(
        existence=None,
        and_=[
            recs_filter.TFilter(existence=None,
                                and_=None,
                                or_=None,
                                recency=None,
                                overlap=None,
                                any=None,
                                named='GLOBAL',
                                range=None),
            recs_filter.TFilter(existence=None,
                                and_=None,
                                or_=None,
                                recency=recs_filter.TRecencyFilter(
                                    range=recs_filter.TRange(min_=-604800.0,
                                                             max_=None),
                                    field='pubDate'),
                                overlap=None,
                                any=None,
                                named=None,
                                range=None),
            recs_filter.TFilter(existence=None,
                                and_=None,
                                or_=None,
                                recency=None,
                                overlap=recs_filter.TOverlapFilter(
                                    amount=recs_filter.TRange(min_=1.0,
                                                              max_=None),
                                    values=['top story', 'lead story'],
                                    field='tag',
                                    match_type=0),
                                any=None,
                                named=None,
                                range=None),
            recs_filter.TFilter(
                existence=None,
                and_=None,
                or_=None,
                recency=None,
                overlap=recs_filter.TOverlapFilter(
                    amount=recs_filter.TRange(min_=1.0, max_=None),
                    values=[
                        'broadband plans', 'streaming', 'music streaming',
                        'apps', 'mobile plans', 'cheap phones', 'software',
                        'gaming', 'wearables', 'internet tv',
                        'virtual privacy network', 'technology',
                        'mobile phones', 'nbn tracker'
                    ],
                    field='section',
                    match_type=0),
                any=None,
                named=None,
                range=None)
        ],
        or_=None,
        recency=None,
        overlap=None,
        any=None,
        named=None,
        range=None)

    request.groups['finder_tech'] = req.RecGroupRequest(count=COUNT,
                                                        metafilter=metafilter)

    config = {'host': rts_host, 'port': PORT, 'timeout': TIMEOUT}
    with RecommendationsClient(calling_app=CALLING_APP, **config) as client:
        response = client.get_recommendations(request)
    assert len(response) == COUNT