def test_save_workspace(): pm = PackageManager() pm.init() asession = Session() import sys sgfactory = CompositeNodeFactory(name="SubGraphExample", description= "Examples", category = "Examples", ) sg= CompositeNode() # build the subgraph factory addid = sg.add_node(pm.get_node("pkg_test", "float")) sg.to_factory(sgfactory) instance = sgfactory.instantiate() instance.actor(addid).set_input(0, 3) asession.add_workspace(instance) asession.save('test.pic') asession.workspaces = [] asession.load('test.pic') try: os.remove('test.pic') except: os.remove('test.pic.db') i = asession.workspaces[0] assert type(i) == type(instance)
def test_save_workspace(): pm = PackageManager() pm.init() asession = Session() import sys sgfactory = CompositeNodeFactory( name="SubGraphExample", description="Examples", category="Examples", ) sg = CompositeNode() # build the subgraph factory addid = sg.add_node(pm.get_node("pkg_test", "float")) sg.to_factory(sgfactory) instance = sgfactory.instantiate() instance.actor(addid).set_input(0, 3) asession.add_workspace(instance) asession.save('test.pic') asession.workspaces = [] asession.load('test.pic') try: os.remove('test.pic') except: os.remove('test.pic.db') i = asession.workspaces[0] assert type(i) == type(instance)
def test_save_datapool(): asession = Session() datapool = asession.datapool datapool['i'] = [1, 2, 3] add_user_class(datapool) asession.save('test.pic') asession.datapool.clear() asession.load('test.pic') assert asession.datapool['i'] == [1, 2, 3] try: os.remove('test.pic') except: os.remove('test.pic.db')