<commit_before>import ulmo

import test_util


test_sets = [
    {
        'state': 'AL',
        'climate_division': 1,
        'values': [{
            'cmi': 0.05,
            'pdsi': 0.53,
            'period': '2010-06-06/2010-06-12',
            'potential_evap': 1.37,
            'precipitation': 0.71,
            'runoff': 0.0,
            'soil_moisture_lower': 4.86,
            'soil_moisture_upper': 0.0,
            'temperature': 77.6
        }]
    },
]


def test_get_data_by_state():
    with test_util.mocked_requests('cpc/drought/palmer10'):
        data = ulmo.cpc.drought.get_data(state='AL', start='2010-5-20',
                end='2010-6-13')
    assert len(data) == 1
    assert 'AL' in data


def test_get_data():
    with test_util.mocked_requests('cpc/drought/palmer10'):
        data = ulmo.cpc.drought.get_data(start='2010-5-20', end='2010-6-13')

    for test_set in test_sets:
        values = data.get(test_set['state'], {}).get(test_set['climate_division'])
        test_values = test_set['values']

        for test_value in test_values:
            assert test_value in values<commit_msg>add test that as_dataframe is working<commit_after>import pandas

import ulmo

import test_util


test_sets = [
    {
        'state': 'AL',
        'climate_division': 1,
        'values': [{
            'cmi': 0.05,
            'pdsi': 0.53,
            'period': '2010-06-06/2010-06-12',
            'potential_evap': 1.37,
            'precipitation': 0.71,
            'runoff': 0.0,
            'soil_moisture_lower': 4.86,
            'soil_moisture_upper': 0.0,
            'temperature': 77.6
        }]
    },
]


def test_get_data_by_state():
    with test_util.mocked_requests('cpc/drought/palmer10'):
        data = ulmo.cpc.drought.get_data(state='AL', start='2010-5-20',
                end='2010-6-13')
    assert len(data) == 1
    assert 'AL' in data


def test_get_data():
    with test_util.mocked_requests('cpc/drought/palmer10'):
        data = ulmo.cpc.drought.get_data(start='2010-5-20', end='2010-6-13')

    for test_set in test_sets:
        values = data.get(test_set['state'], {}).get(test_set['climate_division'])
        test_values = test_set['values']

        for test_value in test_values:
            assert test_value in values


def test_get_data_as_dataframe():
    with test_util.mocked_requests('cpc/drought/palmer10'):
        data = ulmo.cpc.drought.get_data(start='2010-5-20', end='2010-6-13',
                as_dataframe=True)

        assert isinstance(data, pandas.DataFrame)
{'fraction_non_alphanumeric': 0.14442700156985872, 'fraction_numerical': 0.06279434850863422, 'mean_word_length': 2.238881829733164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2610516', 'n_tokens_mistral': 1015, 'n_tokens_neox': 892, 'n_words': 151}