def test_set_board_state(): b = Board() assert b.get("test_key") is None set_board = SetBoardState("set", "test_key", "hello") set_board.start(b) set_board.wait() assert b.get("test_key") == "hello" assert b.get("test_key")
def test_load_dictionary(): b = Board() check_dict = {'k1': 'Hello', 'k2': 800} b.load(check_dict) assert b.get('k1') == 'Hello' assert b.get('k2') == 800 check_dict['k2'] = 100 assert b.get('k2') == 800 # try replacing a previous value check_dict_2 = {'k2': 1000} b.load(check_dict_2) assert b.get('k2') == 1000
def test_board_set_deep_copy(): b = Board() test_obj = {'hello': 'world'} b.set('obj', test_obj, deep_copy=False) test_obj['hello'] = 'test' assert b.get('obj')['hello'] == 'test' assert b.get('obj')['hello'] != 'world'
def test_internal_set(): s1 = DummyState('s1') set_state = SetState('set', 'key', 'hello') s1.add_transition_on_success(set_state) exe = Machine("xe", s1) b = Board() exe.start(b, manual_exec=True) exe.update(b, wait=True) assert b.get('key') == 'hello'
def test_board_get_deep_copy(): b = Board() test_obj = {'hello': 'world'} b.set('obj', test_obj, deep_copy=False) rtn_obj = b.get('obj', False) assert rtn_obj['hello'] == 'world' test_obj['hello'] = 'test' assert rtn_obj['hello'] == 'test'
def test_internal_get(): s1 = DummyState('s1') get_state = GetState('set', 'key') s1.add_transition_on_success(get_state) exe = Machine("xe", s1) b = Board() b.set("key", "hello_get") exe.start(b, manual_exec=True) exe.update(b, wait=True) assert b.get('output') == 'hello_get'
def test_get_non_exist(): b = Board() assert b.get('key') is None
def test_replaced_set(): b = Board() b.set("x", "hello") b.set("x", "world") assert b.get('x') == 'world'
def test_external_set_get(): b = Board() b.set("x", "key1") assert b.get('x') == 'key1'