def test_change_params_dict2(): params = {'Algorithm': {2: {'expression': {'content': 1.}}}} p = convert_xml_dict(pytest.XML_PATH) set_params(p, **params) base = p['Simulation']['Algorithms']['Algorithm'][2] assert base['expression']['content'] == 1. assert base['type'] == "RateFunctor"
def test_set_value_no_content(): params = {'t_end': .01} p = convert_xml_dict(pytest.XML_PATH) q = copy.deepcopy(p) set_params(q, **params) assert p == q set_params(p, t_end=1) assert p['Simulation']['SimulationRunParameter']['t_end']['content'] == 1
def test_change_params_dict(): params = {'Connection': {3: {'content': '-1000 100. 0001'}}} p = convert_xml_dict(pytest.XML_PATH) set_params(p, **params) base = p['Simulation']['Connections']['Connection'][3] assert base['content'] == '-1000 100. 0001' assert base['In'] == 'adex E' assert base['Out'] == 'adex I'
def test_set_multiple_values(): from miindio.tools import dump_xml params = { 'Algorithm': '2/expression/2000.', 'Connection': { 2: '50 -1 1', 3: '200 1 1' } } p = convert_xml_dict(pytest.XML_PATH) set_params(p, **params) dump_xml(p, pytest.PATH + '.xml') base = p['Simulation']['Algorithms']['Algorithm'][2] assert base['expression']['content'] == 2000.
def test_set_no_content_deep_string(): p = convert_xml_dict(pytest.XML_PATH) set_params(p, Algorithm='2/expression/1.') base = p['Simulation']['Algorithms']['Algorithm'][2] assert base['expression']['content'] == 1. assert base['type'] == "RateFunctor"
def test_set_attr(): p = convert_xml_dict(pytest.XML_PATH) set_params(p, Node='0/algorithm/yoyo') assert p['Simulation']['Nodes']['Node'][0]['algorithm'] == 'yoyo'
def test_set_val_new_structure(): p = convert_xml_dict(pytest.XML_PATH) with pytest.raises(TypeError): set_params(p, Algorithm='2/1')
def test_set_val_new_type(): p = convert_xml_dict(pytest.XML_PATH) with pytest.raises(TypeError): set_params(p, Algorithm='2/expression/1')