def test_config1(self): """test emuML with create dispose, holder and push observer""" import test_sim1 as sim m1 = sim.get_model() efile = emuML.EmulationWriter(m1) output = efile.write() f = open(os.path.join(os.path.dirname(__file__), 'data', "sim1.xml"), 'r') exp_output = f.read() f.close() self.assertTrue(self.compare_dom(output, exp_output)) m2 = emuML.load( os.path.join(os.path.dirname(__file__), 'data', "sim1.xml")) output = emuML.save(m2) self.assertTrue(self.compare_dom(output, exp_output)) m3 = emuML.load( os.path.join(os.path.dirname(__file__), 'data', "sim1.xml")) sim.register_control(m3) m3.emulate(until=sim.EMULATE_UNTIL) result = [(pid, p.shape_history, p.space_history, p.create_time, p.dispose_time) for (pid, p) in m3.products.items()] self.assertEqual(result, sim.EXP_RESULT)
def test_config5(self): """Test emuML with physical properties""" import test_sim14 as sim sim_file = os.path.join(os.path.dirname(__file__), 'data', "sim14.xml") m1 = sim.get_model() output = emuML.save(m1) #test whether output equals sim4.xml... f = open(sim_file, 'r') exp_output = f.read() f.close() self.assertTrue(self.compare_dom(output, exp_output)) m2 = emuML.load(sim_file) output = emuML.save(m2) self.assertTrue(self.compare_dom(output, exp_output)) m3 = emuML.load(sim_file) sim.register_control(m3) m3.emulate(until=sim.EMULATE_UNTIL) result = [(pid, p.shape_history, p.space_history, dict([(key, p[key]) for key in p.properties.keys()]), p.create_time, p.dispose_time) for (pid, p) in m3.products.items()] result_resource = [ m3.modules["transporter"].trace, m3.modules["machine"].trace ] self.assertEqual(result, sim.EXP_RESULT_PRODUCT) self.assertEqual(result_resource, sim.EXP_RESULT_RESOURCE)
def test_config2(self): """test emuML with create, space, shape, pushobserver""" import test_sim4 as sim m1 = sim.get_model() output = emuML.save(m1) #test whether output equals sim4.xml... f = open(os.path.join(os.path.dirname(__file__), 'data', "sim4.xml"), 'r') exp_output = f.read() f.close() self.assertTrue(self.compare_dom(output, exp_output)) m2 = emuML.load( os.path.join(os.path.dirname(__file__), 'data', "sim4.xml")) output = emuML.save(m2) self.assertTrue(self.compare_dom(output, exp_output)) m3 = emuML.load( os.path.join(os.path.dirname(__file__), 'data', "sim4.xml")) sim.register_control(m3) m3.emulate(until=sim.EMULATE_UNTIL) result_product = [(pid, p.shape_history, p.space_history, p.create_time, p.dispose_time) for (pid, p) in m3.products.items()] result_resource = [ m3.modules["transporter"].trace, m3.modules["machine"].trace ] self.assertEqual(result_product, sim.EXP_RESULT_PRODUCT) self.assertEqual(result_resource, sim.EXP_RESULT_RESOURCE)
def test_config4(self): """test emuML with create, holder with speed and capacity, pushobserver, pullobserver""" import test_sim8 as sim sim_file = os.path.join(os.path.dirname(__file__), 'data', "sim8.xml") m1 = sim.get_model() output = emuML.save(m1) #test whether output equals sim4.xml... f = open(sim_file, 'r') exp_output = f.read() f.close() self.assertTrue(self.compare_dom(output, exp_output)) m2 = emuML.load(sim_file) output = emuML.save(m2) self.assertTrue(self.compare_dom(output, exp_output)) m3 = emuML.load(sim_file) sim.register_control(m3) m3.emulate(until=sim.EMULATE_UNTIL) result = [(pid, p.shape_history, p.space_history, p.create_time, p.dispose_time) for (pid, p) in m3.products.items()] self.assertEqual(result, sim.EXP_RESULT)
def test_config6(self): import test_sim15 as sim m1 = sim.get_model() sim_file = os.path.join(os.path.dirname(__file__), 'data', "sim15.xml") output = emuML.save(m1) f = open(sim_file, 'r') exp_output = f.read() f.close() self.assertTrue(self.compare_dom(output, exp_output)) m3 = emuML.load(sim_file) #sim.register_control_submodel(m3.modules['cell']) sim.register_control(m3) m3.emulate(until=sim.EMULATE_UNTIL) result = [(pid, p.shape_history, p.space_history, p.create_time, p.dispose_time) for (pid, p) in m3.products.items()] result_resource = [ m3.get_module("cell.transporter").trace, m3.get_module("cell.machine").trace ] self.assertEqual(result, sim.EXP_RESULT_PRODUCT) self.assertEqual(result_resource, sim.EXP_RESULT_RESOURCE)