예제 #1
0
def test_load_backup(backup, correct_timeseries):
    """Test for load backup method

    :param:
    :return:

    """

    _time_line_manager = TimeLineManager()
    _time_line_manager.load_backup(backup)

    actual = _time_line_manager.get_backup()['timescales']
    expected = backup['timescales']

    assert len(actual) == len(expected)

    assert [i['name'] for i in expected].sort() == \
           [i['name'] for i in actual].sort()

    assert sorted([(i['name'], len(i['timeline'])) for i in expected], key=lambda l: l[1]) == \
           sorted([(i['name'], len(i['timeline'])) for i in actual], key=lambda l: l[1])

    actual = _time_line_manager._timescales
    expected = correct_timeseries
    assert len(actual) == len(expected)

    assert [i['name'] for i in expected].sort() == \
           [i['name'] for i in actual].sort()

    assert sorted([(i['name'], len(i['timeline'])) for i in expected], key = lambda l: l[1]) == \
           sorted([(i['name'], len(i['timeline'])) for i in actual], key = lambda l: l[1])
예제 #2
0
def test_load_timelines_raise_exception_value_error():
    """Check exception on wrong input value
    :return:
    """
    with pytest.raises(Exception):
        _time_line_manager = TimeLineManager()
        _time_line_manager.load_timelines({'1': '2'}, {'1': '2'}, {'1': '2'})
예제 #3
0
def test_load_timelines_raise_exception_type_error():
    """
    Check exception on wrong input type
    :return:

    """
    with pytest.raises(Exception):
        _time_line_manager = TimeLineManager()
        _time_line_manager.load_timelines(1, 2, 3)
예제 #4
0
def test_load_backup_raise_exception_type_error():
    """Test for load backup method
    Check exception on wrong input type
    :param:
    :return:

    """

    with pytest.raises(Exception):
        _time_line_manager = TimeLineManager()
        _time_line_manager.load_backup('backup')
예제 #5
0
def timeline_manager(data):
    '''Timeline manager preparation

    :param data:
    :return:

    '''
    ts_properties = data['properties']
    alias = data['alias']
    top_ts_points = data['top_ts_points']
    _time_line_manager = TimeLineManager()
    _time_line_manager.load_timelines(ts_properties, alias, top_ts_points)
    return _time_line_manager
예제 #6
0
def time_line_manager(data):
    """Fixture that prepare timeline manager

    :param data:
    :return:

    """
    ts_properties = data['properties']
    alias = data['alias']
    top_ts_points = data['top_ts_points']

    _time_line_manager = TimeLineManager()
    _time_line_manager.load_timelines(ts_properties, alias, top_ts_points)
    return _time_line_manager