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 == ""
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)
def setup_method(self): self.__tmpdir = create_tmp_dir() self.oconfig = xh.default_config self._filename = os.path.join(self.__tmpdir, "reqs.xlsx") self.oconfig["output_filename"] = self._filename self.oconfig["template_filename"] = os.path.join( LDIR, 'DefaultTemplate.xlsx')
def setup_class(self): cdir = os.path.dirname(os.path.realpath(__file__)) self.__tmpdir = create_tmp_dir() self.__def_mconfig = { "output_filename": os.path.join(self.__tmpdir, "TestLateXJinja2Out.tex"), "template_path": os.path.join(cdir, 'LatexJinja2') }
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)
def tmpdir(): tmpdir = create_tmp_dir() yield tmpdir delete_tmp_dir(tmpdir)
def prepare_result_is_dir(): td = create_tmp_dir() os.environ["rmtoo_test_dir"] = td mout, merr = create_std_log(td) return mout, merr