<gh_stars>0
import os
import pandas as pd
from toucan_data_sdk.utils.generic import roll_up


fixtures_base_dir = 'tests/fixtures'


def test_roll():
    """
    It should return the same DataFrame as the one after a roll_up

    """
    input_df = pd.read_csv(os.path.join(fixtures_base_dir, 'roll_up_in.csv'))
    res_df = roll_up(input_df,
                     levels=['Country', 'Region', 'City'],
                     groupby_vars=['value', 'population'],
                     value_name='Location',
                     var_name='Type')
    res_df = res_df[['Location', 'Type', 'population', 'value', 'Country', 'Region', 'City']]
    expected_output = pd.read_csv(os.path.join(fixtures_base_dir, 'roll_up.csv'))
    assert res_df.equals(expected_output)

import os
import pandas as pd
from toucan_data_sdk.utils.generic import roll_up


fixtures_base_dir = 'tests/fixtures'


def test_roll():
    """
    It should return the same DataFrame as the one after a roll_up

    """
    input_df = pd.read_csv(os.path.join(fixtures_base_dir, 'roll_up_in.csv'))
    res_df = roll_up(input_df,
                     levels=['Country', 'Region', 'City'],
                     groupby_vars=['value', 'population'],
                     value_name='Location',
                     var_name='Type')
    res_df = res_df[['Location', 'Type', 'population', 'value', 'Country', 'Region', 'City']]
    expected_output = pd.read_csv(os.path.join(fixtures_base_dir, 'roll_up.csv'))
    assert res_df.equals(expected_output)
It should return the same DataFrame as the one after a roll_up