예제 #1
0
def test_from_dict():
    state = State.from_dict({
        'height_files': ['foo', 'bar'],
        'osm_files': ['hello', 'world'],
        'window': {
            'ulx': 1,
            'uly': 2,
            'lrx': 3,
            'lry': 4
        }
    })
    assert ['foo', 'bar'] == state.height_files
    assert ['hello', 'world'] == state.osm_files
    assert (1, 2) == state.get_window_upper_left()
    assert (3, 4) == state.get_window_lower_right()
예제 #2
0
def load_state():
    if state_exists():
        with open(state_path(), 'r') as infile:
            return State.from_dict(json.load(infile))
    else:
        return init_state()