Esempio n. 1
0
def test_should_handle_pageloads_with_empty_sponsors(sqs_client):
    metrics = mock.Mock(spec_set=MetricsLogger)
    queue_url = 'some-queue-url'
    with Stubber(sqs_client) as stubber:
        stubber.add_response(
            'send_message',
            {},
            dict(QueueUrl=queue_url, MessageBody=make_expected_body('PageLoad', ''))
        )
        handle_pageload(dict(queryStringParameters=dict(icons='')), metrics, SOME_DATE, queue_url, sqs_client)
    metrics.set_property.assert_called_once_with('sponsors', [])
Esempio n. 2
0
def test_pageloads_should_return_a_200_doc():
    metrics = mock.Mock(spec_set=MetricsLogger)
    queue_url = 'some-queue-url'
    result = handle_pageload(dict(queryStringParameters={}), metrics, SOME_DATE, queue_url, mock.Mock())
    assert result['statusCode'] == 200
    assert result['body'] == 'Ok'
    metrics.put_metric.assert_called_once_with('PageLoad', 1)
Esempio n. 3
0
def test_should_handle_pageloads_with_many_sponsors_uri_encoded(sqs_client):
    metrics = mock.Mock(spec_set=MetricsLogger)
    queue_url = 'some-queue-url'
    with Stubber(sqs_client) as stubber:
        stubber.add_response('send_message', {}, dict(QueueUrl=queue_url, MessageBody=ANY))
        for expectation in ('bob', 'alice', 'crystal'):
            stubber.add_response(
                'send_message',
                {},
                dict(QueueUrl=queue_url, MessageBody=make_expected_body('SponsorView', expectation)))
        handle_pageload(
            dict(queryStringParameters=dict(icons='bob%2Calice%2Ccrystal')),
            metrics,
            SOME_DATE,
            queue_url,
            sqs_client)
    metrics.set_property.assert_called_once_with('sponsors', ['bob', 'alice', 'crystal'])