Exemplo n.º 1
0
    def test_display_astk_parameters_for_solver(self):
        cfg = astk.Cfg()
        cfg.add("dbg", astk.Param("debug", "nodebug"))
        cfg.add("mem", astk.Attr("memory", 128))

        cparams = aster_s.AstkParams(cfg)
        cparams.name = "p"
        params = cparams.build(self.std)
        pnode = params.node
        self.assertEqual(params.read_name(), "p")
        params.attach_cfg(cfg)
        dbg = ST.Line(pnode.find_node("dbg"))
        self.assertEqual(dbg.read_name(), "dbg")
        self.assertEqual(dbg.read_value(), "nodebug")
        self.assertEqual(params["dbg"], "nodebug")

        mem = ST.Line(pnode.find_node("mem"))
        self.assertEqual(mem.read_value(), 128)
        self.assertEqual(mem.read_visible_value(), '128')
        params["mem"] = 256
        self.assertEqual(mem.read_value(), 256)
        self.assertEqual(mem.read_visible_value(), '256')
        
        params["dbg"] = "debug"
        astk_cfg = params.get_cfg()
        self.assertEqual(astk_cfg["mem"].value, 256)
        self.assertEqual(astk_cfg["dbg"].value, "debug")
 def test_check_two_configuration_equality(self):
     cfgs = [AS.Cfg() for idx in range(2)]
     for cfg in cfgs:
         cfg.add("v", AS.Param("v", "v1"))
         cfg.add("p", AS.Attr("p", "p1"))
     self.assert_(cfgs[0] is not cfgs[1])
     self.assert_(cfgs[0].equal(cfgs[1]))
     cfgs[0]["v"].value = "v2"
     self.assert_(not cfgs[0].equal(cfgs[1]))
    def test_copy_configuration(self):
        cfg = AS.Cfg()
        cfg.add("v", AS.Param("v", "v1"))
        cfg.add("c", AS.Attr("m", "f"))
        copy = cfg.copy()
        self.assert_(copy is not cfg)
        self.assert_(copy.equal(cfg))

        self.assert_(cfg["v"] is not copy["v"])
        self.assert_(cfg["c"] is not copy["c"])
Exemplo n.º 4
0
    def test_clear_section_when_new_configuration_attached(self):
        cfg = astk.Cfg()
        cfg.add("mem", astk.Attr("memory", 128))
        parent = AS.Elt(self.std.node.add_node("p"), AS.Elt)

        cparams = aster_s.AstkParams(cfg)
        params = cparams.build(parent)
        mem = params.get_elt("mem")
        self.assert_(mem.node.is_alive())
        
        cfg = astk.Cfg()
        cfg.add("dbg", astk.Param("debug"))
        params.attach_cfg(cfg)
        self.assert_(not mem.node.is_alive())
    def test_build_export_file(self):
        rep = self.tmp_dir.add("build")
        comm = get_data("forma01a.comm")
        med = get_data("forma01a.comm")
        cfg = AS.Cfg()
        cfg.add("v", AS.Param("version", "STA10.0"))
        cfg.add("name", AS.Param("nomjob"))
        cfg.add("m", AS.Param("mode", "bash"))
        cfg.add("n", AS.Attr("nb-cpu", 2))

        bld = AS.ExportFileBuilder("forma01-case")
        bld.working_dir = rep
        bld.add(cfg)
        bld.add(AS.RMessFile())
        bld.add(AS.CommFile(comm))
        bld.add(AS.MedFile(med))
        bld.add(AS.RResuFile())
        bld.add(AS.RRMedFile())
        bld.add(AS.Base())

        fname = bld.write().fname

        fpat = osp.join(rep, "forma01-case")
        self.assertEqual(fname, fpat + ".export")
        res = [
            "P version STA10.0",
            "P nomjob forma01-case",
            "P mode bash",
            "A nb-cpu 2",
            "F comm %s D 1" % comm,
            "F mmed %s D 20" % med,
            "F mess %s R 6" % (fpat + ".mess"),
            "F resu %s R 8" % (fpat + ".resu"),
            "F rmed %s R 80" % (fpat + ".rmed"),
            "R base %s RC 0" % (fpat + "base"),
        ]
        fid = open(fname)
        expf = fid.read()
        for line in res:
            self.assert_(line in expf, "not found : %s" % line)
        fid.close()