Пример #1
0
def test_parsing_with_user_ids_limit():
    data = {
        'task_1':
        '{"result": {"message": "text", "vk_attachment_id": 1, "user_id": 1}}',
        'task_2':
        '{"result": {"message": "text", "vk_attachment_id": 1, "user_id": 2}}',
        'task_3':
        '{"result": {"message": "text", "vk_attachment_id": 1, "user_id": 3}}',
    }
    actual_result = parse_redis_data(data, user_ids_limit=2)
    expected_results = [{
        'data': {
            ('text', 1): {1, 2}
        },
        'checked_keys': {'task_1', 'task_2'}
    }, {
        'data': {
            ('text', 1): {2, 3}
        },
        'checked_keys': {'task_2', 'task_3'}
    }, {
        'data': {
            ('text', 1): {1, 3}
        },
        'checked_keys': {'task_1', 'task_3'}
    }]
    assert actual_result in expected_results
Пример #2
0
def test_parsing_with_execute_limit():
    data = {
        'task_1':
        '{"result": {"message": "one", "vk_attachment_id": 1, "user_id": 1}}',
        'task_2':
        '{"result": {"message": "two", "vk_attachment_id": 2, "user_id": 2}}',
        'task_3':
        '{"result": {"message": "three", "vk_attachment_id": 3, "user_id": 3}}',
    }
    actual_result = parse_redis_data(data, execute_limit=2)
    expected_results = [{
        'data': {
            ('one', 1): {1},
            ('two', 2): {2}
        },
        'checked_keys': {'task_1', 'task_2'}
    }, {
        'data': {
            ('two', 2): {2},
            ('three', 3): {2}
        },
        'checked_keys': {'task_2', 'task_3'}
    }, {
        'data': {
            ('one', 1): {1},
            ('three', 3): {3}
        },
        'checked_keys': {'task_1', 'task_3'}
    }]
    assert actual_result in expected_results
Пример #3
0
def test_parsing_incorrect_data():
    data = {'task_1': '"one"', 'task_2': '"two"', 'task_3': '"three"'}
    actual_result = parse_redis_data(data)
    expected_result = {
        'data': {},
        'checked_keys': {'task_1', 'task_2', 'task_3'}
    }
    assert actual_result == expected_result
Пример #4
0
def test_parsing_regular_data():
    data = {
        'task_1':
        '{"result": {"message": "text", "vk_attachment_id": 1, "user_id": 1}}',
        'task_2':
        '{"result": {"message": "text", "vk_attachment_id": 1, "user_id": 2}}',
    }
    actual_result = parse_redis_data(data)
    expected_result = {
        'data': {
            ('text', 1): {1, 2}
        },
        'checked_keys': {'task_1', 'task_2'}
    }
    assert actual_result == expected_result
Пример #5
0
def test_parsing_empty_data():
    assert parse_redis_data({}) is None