(restore_user, indicator_set)
return fixture
Generate the fixture from the indicator data.

    :param user: The user.
    :param indicator_set: A subclass of SqlIndicatorSet
Generate the fixture from the indicator data.
Generate the fixture from the indicator data .
def gen_fixture(restore_user, indicator_set):
    """
    Generate the fixture from the indicator data.

    :param user: The user.
    :param indicator_set: A subclass of SqlIndicatorSet
    """
    """
    Example output:

    indicator_set.name = 'demo'
    indicator_set.get_data() = {'user_case1': {'indicator_a': 1, 'indicator_b': 2}}

    <fixture id="indicators:demo" user_id="...">
        <indicators>
            <case id="user_case1">
                <indicator_a>1</indicator_a>
                <indicator_b>2</indicator_2>
            </case>
        </indicators>
    </fixture>
    """
    assert indicator_set is not None

    name = indicator_set.name
    data = indicator_set.get_data()

    fixture = ElementTree.Element('fixture', {
        'id': ':'.join((IndicatorsFixturesProvider.id, name)),
        'user_id': restore_user.user_id,
        'date': indicator_set.reference_date.isoformat()
    })
    indicators_node = ElementTree.SubElement(fixture, 'indicators')
    for case_id, indicators in data.items():
        group = ElementTree.SubElement(indicators_node, 'case', {'id': case_id})
        for name, value in indicators.items():
            indicator = ElementTree.SubElement(group, name)
            indicator.text = str(value)

    return fixture
def gen_fixture ( restore_user , indicator_set ) : """
    Example output:

    indicator_set.name = 'demo'
    indicator_set.get_data() = {'user_case1': {'indicator_a': 1, 'indicator_b': 2}}

    <fixture id="indicators:demo" user_id="...">
        <indicators>
            <case id="user_case1">
                <indicator_a>1</indicator_a>
                <indicator_b>2</indicator_2>
            </case>
        </indicators>
    </fixture>
    """ assert indicator_set is not None name = indicator_set . name data = indicator_set . get_data ( ) fixture = ElementTree . Element ( 'fixture' , { 'id' : ':' . join ( ( IndicatorsFixturesProvider . id , name ) ) , 'user_id' : restore_user . user_id , 'date' : indicator_set . reference_date . isoformat ( ) } ) indicators_node = ElementTree . SubElement ( fixture , 'indicators' ) for case_id , indicators in data . items ( ) : group = ElementTree . SubElement ( indicators_node , 'case' , { 'id' : case_id } ) for name , value in indicators . items ( ) : indicator = ElementTree . SubElement ( group , name ) indicator . text = str ( value ) return fixture