Exemple #1
0
    def rmttest_json_init_add_new_cmd_line_params(self):
        '''Init Cfg with JSON and adds parameters with command line options'''
        mstderr = StringIO()
        init_logger(mstderr)

        # Create two JSON files.
        tmpdir = create_tmp_dir()
        jsonfile1 = os.path.join(tmpdir, "config1.json")
        with open(jsonfile1, "w") as jsonfd1:
            jsonfd1.write(json.dumps({'k': 2, 'm': {'n': 5}, 'o': 7}))

        jsonfile2 = os.path.join(tmpdir, "config2.json")
        with open(jsonfile2, "w") as jsonfd2:
            jsonfd2.write(json.dumps({'k': 3, 'm': {'w': 11}, 'p': 9}))

        config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}')
        config.merge_cmd_line_params([
            '-j', '{"m": {"p": 99}}', '-j', 'file://' + jsonfile1, '-j',
            '{"m": {"q": 100}}', '-j', 'file://' + jsonfile2
        ])
        assert 1 == config.get_value("k"), "k is not 1"
        config.evaluate()
        assert 3 == config.get_value("k"), "k is not 3"
        assert 11 == config.get_value("m.w")
        lstderr = hide_volatile(mstderr.getvalue())
        shutil.rmtree(tmpdir)
        tear_down_log_handler()
        assert lstderr == ""
Exemple #2
0
    def rmttest_neg_01(self):
        "LaTeX output: check invalid tag in topic"

        tcfg = TestConfig()
        tcfg.set_output_cfg()

        tvcs = TestVCS(tcfg)
        tfile = tvcs.get_tfile1()

        topic = Topic(None, u"TName", tvcs, None, tfile, None)
        topic.t = [
            RecordEntry(u"CompleteleOther", u"My content"),
        ]
        tmpdir = create_tmp_dir()

        rset = RequirementSet(tcfg)

        ttopic_set = TestTopicSet(rset)

        mconfig = {
            "output_filename": os.path.join(tmpdir, "TestLateX2Out.tex")
        }
        out_l2 = latex2(mconfig)

        try:
            out_l2.topic_set_pre(ttopic_set)
            topic.execute(out_l2, "")
            assert False
        except RMTException:
            pass
        out_l2.topic_set_post(ttopic_set)
        delete_tmp_dir(tmpdir)
Exemple #3
0
    def test_json_init_add_new_cmd_line_params(self):
        '''Init Cfg with JSON and adds parameters with command line options'''
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        # Create two JSON files.
        tmpdir = create_tmp_dir()
        jsonfile1 = os.path.join(tmpdir, "config1.json")
        jsonfd1 = file(jsonfile1, "w")
        jsonfd1.write(json.dumps({'k': 2, 'm': {'n': 5}, 'o': 7}))
        jsonfd1.close()
        jsonfile2 = os.path.join(tmpdir, "config2.json")
        jsonfd2 = file(jsonfile2, "w")
        jsonfd2.write(json.dumps({'k': 3, 'm': {'w': 11}, 'p': 9}))
        jsonfd2.close()

        config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}')
        config.merge_cmd_line_params([
            '-j', '{"m": {"p": 99}}', '-j', 'file://' + jsonfile1, '-j',
            '{"m": {"q": 100}}', '-j', 'file://' + jsonfile2
        ])
        self.failUnlessEqual(1, config.get_value("k"), "k is not 1")
        config.evaluate()
        self.failUnlessEqual(3, config.get_value("k"), "k is not 3")
        self.failUnlessEqual(11, config.get_value("m.w"))
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        self.failUnlessEqual(lstderr, "")
    def test_json_init_add_new_cmd_line_params(self):
        '''Init Cfg with JSON and adds parameters with command line options'''
        log_store = MemLogStore()

        # Create two JSON files.
        tmpdir = create_tmp_dir()
        jsonfile1 = os.path.join(tmpdir, "config1.json")
        jsonfd1 = file(jsonfile1, "w")
        jsonfd1.write(json.dumps({'k': 2 , 'm': {'n': 5}, 'o': 7}))
        jsonfd1.close()
        jsonfile2 = os.path.join(tmpdir, "config2.json")
        jsonfd2 = file(jsonfile2, "w")
        jsonfd2.write(json.dumps({'k': 3 , 'm': {'w': 11}, 'p': 9}))
        jsonfd2.close()

        config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}');
        config.merge_cmd_line_params(['-j', '{"m": {"p": 99}}',
                                      '-j', 'file://' + jsonfile1,
                                      '-j', '{"m": {"q": 100}}',
                                      '-j', 'file://' + jsonfile2])
        self.failUnlessEqual(1, config.get_value("k"), "k is not 1")
        config.evaluate(log_store)
        self.failUnlessEqual(3, config.get_value("k"), "k is not 3")
        self.failUnlessEqual(11, config.get_value("m.w"))
        self.failUnlessEqual(MemLogStore.create_mls([]), log_store)
    def test_json_init_add_new_cmd_line_params(self):
        '''Init Cfg with JSON and adds parameters with command line options'''
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        # Create two JSON files.
        tmpdir = create_tmp_dir()
        jsonfile1 = os.path.join(tmpdir, "config1.json")
        jsonfd1 = file(jsonfile1, "w")
        jsonfd1.write(json.dumps({'k': 2 , 'm': {'n': 5}, 'o': 7}))
        jsonfd1.close()
        jsonfile2 = os.path.join(tmpdir, "config2.json")
        jsonfd2 = file(jsonfile2, "w")
        jsonfd2.write(json.dumps({'k': 3 , 'm': {'w': 11}, 'p': 9}))
        jsonfd2.close()

        config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}');
        config.merge_cmd_line_params(['-j', '{"m": {"p": 99}}',
                                      '-j', 'file://' + jsonfile1,
                                      '-j', '{"m": {"q": 100}}',
                                      '-j', 'file://' + jsonfile2])
        self.failUnlessEqual(1, config.get_value("k"), "k is not 1")
        config.evaluate()
        self.failUnlessEqual(3, config.get_value("k"), "k is not 3")
        self.failUnlessEqual(11, config.get_value("m.w"))
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        self.failUnlessEqual(lstderr, "")
Exemple #6
0
    def test_neg_01(self):
        "LaTeX output: check invalid tag in topic"

        tcfg = TestConfig()
        tcfg.set_output_cfg()

        tvcs = TestVCS(tcfg)
        tfile = tvcs.get_tfile1()

        dg = Digraph()

        topic = Topic(dg, "TName", tvcs, None, tfile, None)
        topic.t = [RecordEntry("CompleteleOther", "My content"), ]
        tmpdir = create_tmp_dir()

        rset = RequirementSet(tcfg)

        ttopic_set = TestTopicSet(rset)

        mconfig = {"output_filename": os.path.join(tmpdir, "TestLateX2Out.tex")}
        l2 = latex2(mconfig)

        try:
            l2.topic_set_pre(ttopic_set)
            topic.execute(l2, "")
            assert(False)
        except RMTException, rmte:
            pass
    def rmttest_json_init_add_new_cmd_line_params(self):
        '''Init Cfg with JSON and adds parameters with command line options'''
        mstderr = StringIO()
        init_logger(mstderr)

        # Create two JSON files.
        tmpdir = create_tmp_dir()
        jsonfile1 = os.path.join(tmpdir, "config1.json")
        with open(jsonfile1, "w") as jsonfd1:
            jsonfd1.write(json.dumps({'k': 2, 'm': {'n': 5}, 'o': 7}))

        jsonfile2 = os.path.join(tmpdir, "config2.json")
        with open(jsonfile2, "w") as jsonfd2:
            jsonfd2.write(json.dumps({'k': 3, 'm': {'w': 11}, 'p': 9}))

        config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}')
        config.merge_cmd_line_params(['-j', '{"m": {"p": 99}}',
                                      '-j', 'file://' + jsonfile1,
                                      '-j', '{"m": {"q": 100}}',
                                      '-j', 'file://' + jsonfile2])
        assert 1 == config.get_value("k"), "k is not 1"
        config.evaluate()
        assert 3 == config.get_value("k"), "k is not 3"
        assert 11 == config.get_value("m.w")
        lstderr = hide_volatile(mstderr.getvalue())
        shutil.rmtree(tmpdir)
        tear_down_log_handler()
        assert lstderr == ""
Exemple #8
0
 def __init__(self):
     self.__tmpdir = create_tmp_dir()
     self.__def_mconfig = {
         "output_filename":
         os.path.join(self.__tmpdir, "TestLateXJinja2Out.tex"),
         "template_path":
         os.path.join(os.environ['basedir'], 'latex', 'LatexJinja2')
     }
Exemple #9
0
 def setup_class(self):
     self.__tmpdir = create_tmp_dir()
     self.__def_mconfig = {
         "output_filename":
         os.path.join(self.__tmpdir, "TestLateXJinja2Out.tex"),
         "template_path":
         os.path.join(os.environ['contribdir'],
                      'latex', 'LatexJinja2')}
Exemple #10
0
 def setup_class(self):
     self.__tmpdir = create_tmp_dir()
     self.__def_mconfig = {
         "output_filename":
         os.path.join(self.__tmpdir, "TestLateXJinja2Out.tex"),
         "template_path":
         os.path.join(os.environ['contribdir'], 'latex', 'LatexJinja2')
     }
Exemple #11
0
    def rmttest_neg_02(self):
        "LaTeX output: check invalid tag in requirement output config"

        tcfg = TestConfig()
        tcfg.set_output_cfg()

        # ToDo: is this needed? tvcs = TestVCS(tcfg)
        # ToDo: is this needed? tfile = tvcs.get_tfile1()

        tmpdir = create_tmp_dir()
        mconfig = {
            "req_attributes": ["Status", "Class", "DoesNotExists"],
            "output_filename": os.path.join(tmpdir, "TestLateX2Out.tex")
        }

        out_l2 = latex2(mconfig)
        req = Requirement(None, u"TestReq", None, None, None)
        req.values = {}
        req.values[u"Name"] = RecordEntry(u"Name", u"my name")
        req.values[u"Type"] = RequirementType.requirement
        req.values[u"Description"] = RecordEntry(u"Description", u"my desc")
        req.values[u"Status"] = RequirementStatusFinished(
            None, u"rid", u"finished:meiner:2011-04-15:4h")
        req.values[u"Class"] = ClassTypeImplementable()

        ce3set = CE3Set()
        ce3 = CE3()
        ce3set.insert(u"TestReq", ce3)

        rset = RequirementSet(tcfg)
        ttopic_set = TestTopicSet(rset)

        try:
            out_l2.topic_set_pre(None)
            req.execute(out_l2, "")
            assert False
        except RMTException:
            pass
        out_l2.topic_set_post(ttopic_set)
        delete_tmp_dir(tmpdir)
Exemple #12
0
    def rmttest_neg_02(self):
        "LaTeX output: check invalid tag in requirement output config"

        tcfg = TestConfig()
        tcfg.set_output_cfg()

        # ToDo: is this needed? tvcs = TestVCS(tcfg)
        # ToDo: is this needed? tfile = tvcs.get_tfile1()

        tmpdir = create_tmp_dir()
        mconfig = {"req_attributes": ["Status", "Class", "DoesNotExists"],
                   "output_filename":
                   os.path.join(tmpdir, "TestLateX2Out.tex")}

        out_l2 = latex2(mconfig)
        req = Requirement(None, u"TestReq", None, None, None)
        req.values = {}
        req.values[u"Name"] = RecordEntry(u"Name", u"my name")
        req.values[u"Type"] = RequirementType.requirement
        req.values[u"Description"] = RecordEntry(u"Description", u"my desc")
        req.values[u"Status"] = RequirementStatusFinished(
            None, u"rid", u"finished:meiner:2011-04-15:4h")
        req.values[u"Class"] = ClassTypeImplementable()

        ce3set = CE3Set()
        ce3 = CE3()
        ce3set.insert(u"TestReq", ce3)

        rset = RequirementSet(tcfg)
        ttopic_set = TestTopicSet(rset)

        try:
            out_l2.topic_set_pre(None)
            req.execute(out_l2, "")
            assert False
        except RMTException:
            pass
        out_l2.topic_set_post(ttopic_set)
        delete_tmp_dir(tmpdir)
Exemple #13
0
    def test_neg_02(self):
        "LaTeX output: check invalid tag in requirement output config"

        tcfg = TestConfig()
        tcfg.set_output_cfg()

        tvcs = TestVCS(tcfg)
        tfile = tvcs.get_tfile1()

        tmpdir = create_tmp_dir()
        mconfig = { "req_attributes": ["Status", "Class", "DoesNotExists"],
                    "output_filename": os.path.join(tmpdir, "TestLateX2Out.tex")}

        l2 = latex2(mconfig)
        req = Requirement(None, "TestReq", None, None, None)
        req.values = {}
        req.values["Name"] = RecordEntry("Name", "my name")
        req.values["Type"] = Requirement.rt_requirement
        req.values["Description"] = RecordEntry("Description", "my desc")
        req.values["Status"] = RequirementStatusFinished(
                None, "rid", "finished:meiner:2011-04-15:4h")
        req.values["Class"] = ClassTypeImplementable()

        dnreq = RequirementDNode(req)

        ce3set = CE3Set()
        ce3 = CE3()
        ce3set.insert("TestReq", ce3)

        rset = RequirementSet(tcfg)
        ttopic_set = TestTopicSet(rset)

        try:
            l2.topic_set_pre(None)
            dnreq.execute(l2, "")
            assert(False)
        except RMTException, rmte:
            pass
Exemple #14
0
def prepare_result_is_dir():
    td = create_tmp_dir()
    os.environ["rmtoo_test_dir"] = td
    mout, merr = create_std_log(td)
    return mout, merr
Exemple #15
0
def prepare_result_is_dir():
    td = create_tmp_dir()
    os.environ["rmtoo_test_dir"] = td
    mout, merr = create_std_log(td)
    return mout, merr