コード例 #1
0
def test_y_agg__changed_callback():
    widget = EncodingWidget(df, encoding, change_hook, ipywidget_factory, testing=True)

    widget._y_agg_changed_callback("name", "old", "new")

    assert encoding.y_aggregation == "new"
    assert change_hook.call_count == 1
コード例 #2
0
def test_log_y_changed_callback():
    widget = EncodingWidget(df, encoding, change_hook, ipywidget_factory, testing=True)

    widget._logarithmic_y_callback("name", "old", "new")

    assert encoding.logarithmic_y_axis == "new"
    assert change_hook.call_count == 1
コード例 #3
0
def test_encoding_with_all_none_doesnt_throw():
    records = [{u'buildingID': 0, u'date': u'6/1/13', u'temp_diff': 12},
               {u'buildingID': 1, u'date': u'6/1/13', u'temp_diff': 0},
               {u'buildingID': 2, u'date': u'6/1/14', u'temp_diff': 11},
               {u'buildingID': 0, u'date': u'6/1/15', u'temp_diff': 5},
               {u'buildingID': 1, u'date': u'6/1/16', u'temp_diff': 19},
               {u'buildingID': 2, u'date': u'6/1/17', u'temp_diff': 32}]
    df = pd.DataFrame(records)

    encoding = Encoding()

    ipywidget_factory = MagicMock()

    EncodingWidget(df, encoding, change_hook, ipywidget_factory, testing=True)

    assert call(description='X', value=None, options={'date': 'date', 'temp_diff': 'temp_diff', '-': None,
                                                      'buildingID': 'buildingID'}) \
        in ipywidget_factory.get_dropdown.mock_calls
    assert call(description='Y', value=None, options={'date': 'date', 'temp_diff': 'temp_diff', '-': None,
                                                      'buildingID': 'buildingID'}) \
        in ipywidget_factory.get_dropdown.mock_calls
    assert call(description='Func.', value='none', options={'Max': 'Max', 'Sum': 'Sum', 'Avg': 'Avg',
                                                            '-': 'None', 'Min': 'Min', 'Count': 'Count'}) \
        in ipywidget_factory.get_dropdown.mock_calls
コード例 #4
0
def test_value_for_aggregation():
    widget = EncodingWidget(df, encoding, change_hook, ipywidget_factory, testing=True)

    assert widget._get_value_for_aggregation(None) == "none"
    assert widget._get_value_for_aggregation("avg") == "avg"