Exemplo n.º 1
0
async def test_github_data_preparer():
    matcher = CountryNameMatcher()
    data: str = await mock_load_github()

    data = GithibDataPreparer.prepare(data, matcher)
    assert type(data) == pd.DataFrame

    columns = data.to_dict()
    check_type(None, columns, Dict[datetime, Dict[str, int]])

    exceptions = {'kosovo'}
    assert set(data.index) - matcher.keys() == exceptions
    assert 'all' in data.index
    assert len(data) > 200
Exemplo n.º 2
0
async def test_region_handling():
    matcher = CountryNameMatcher()
    data: str = await mock_load_github()

    data = GithibDataPreparer._csv_to_dataframe(data)
    data = GithibDataPreparer._colnames_to_datetime(data)
    data = GithibDataPreparer._country_and_region_names_to_keys(data, matcher)

    unhandled_regions = data.filter(['country', 'region']).dropna()
    unhandled_regions = unhandled_regions.loc[~unhandled_regions.region.
                                              isin(matcher.keys())]
    exceptions = {'australia', 'canada', 'china'}
    unhandled_regions = unhandled_regions.loc[~unhandled_regions.country.
                                              isin(exceptions)]
    assert len(unhandled_regions) == 0, str(unhandled_regions)