Esempio n. 1
0
 def test_pos_01(self):
     "Check maybe_remove_last_empty_line with len=0"
     config = {}
     tr = TxtRecord(config)
     sl = []
     tr.maybe_remove_last_empty_line(sl)
     
     assert(len(sl)==0)
Esempio n. 2
0
    def rmttest_pos_01(self):
        "Check maybe_remove_last_empty_line with len=0"
        config = {}
        tr = TxtRecord(config)
        sl = []
        tr.maybe_remove_last_empty_line(sl)

        assert len(sl) == 0
Esempio n. 3
0
    def rmttest_pos_01(self):
        "TestRecordTxt2: empty input"

        txt_doc = TxtRecord.from_string("", "Nothing", TxtIOConfig())

        self.assertEqual(0, len(txt_doc))
        self.assertEqual("", txt_doc.get_comment())
Esempio n. 4
0
    def __read(self, tname, input_handler, commit, file_info, req_set):
        """Read in the topic and create all the tags."""
        self.__tags = TxtRecord.from_string(file_info.get_content(), tname, input_handler.get_txt_io_config())

        for tag in self.__tags:
            # If the topic has subtopics, read them also in.
            if tag.get_tag() == "SubTopic":
                lfile_info = input_handler.get_file_info_with_type(commit, "topics", tag.get_content() + ".tic")
                ntopic = Topic(self.__topicset, self._config, input_handler, commit, lfile_info, req_set)
                # The topic itself is already added in the constrcutor of Topic.
                # Therefore there is no need to add it here (again).
                #                self.__topicset.add_node(ntopic)
                self.__topicset.create_edge(self, ntopic)
            elif tag.get_tag() == "Name":
                if self.__topic_name != None:
                    # TODO: Multiple Names
                    assert False
                self.__topic_name = tag.get_content()
            elif tag.get_tag() == "IncludeRequirements":
                if tag.get_content() != "full":
                    raise RMTException(
                        113, "IncludeRequirements value not " "supported [%s]" % tag.get_content(), self.get_name()
                    )
                self.__requirements = req_set.restrict_to_topics(tname)
                tracer.debug(
                    "Found [%d] requirements for topic [%s]." % (self.__requirements.get_requirements_cnt(), tname)
                )
        # Check for the existence of the name
        if self.__topic_name == None:
            raise RMTException(62, "Mandatory tag 'Name' not given in topic", self.get_name())
Esempio n. 5
0
    def __read(self, tname, input_handler, commit, file_info, req_set):
        '''Read in the topic and create all the tags.'''
        Encoding.check_unicode(tname)
        self.__tags = TxtRecord.from_string(file_info.get_content(), tname,
                                            input_handler.get_txt_io_config())

        for tag in self.__tags:
            # If the topic has subtopics, read them also in.
            if tag.get_tag() == "SubTopic":
                lfile_info = input_handler.get_file_info_with_type(
                    commit, "topics",
                    tag.get_content() + ".tic")
                ntopic = Topic(self.__digraph, self._config, input_handler,
                               commit, lfile_info, req_set)
                self.__digraph.add_node(ntopic)
                Digraph.create_edge(self, ntopic)
            elif tag.get_tag() == "Name":
                if self.__topic_name is not None:
                    # There can (currently) be only one name
                    assert False
                self.__topic_name = tag.get_content()
            elif tag.get_tag() == "IncludeRequirements":
                if tag.get_content() != "full":
                    raise RMTException(
                        113, "IncludeRequirements value not "
                        "supported [%s]" % tag.get_content(), self.name)
                self.__requirements = req_set.restrict_to_topics(tname)
                tracer.debug("Found [%d] requirements for topic [%s]",
                             self.__requirements.get_requirements_cnt(), tname)
        # Check for the existence of the name
        if self.__topic_name is None:
            raise RMTException(62, "Mandatory tag 'Name' not given in topic",
                               self.name)
Esempio n. 6
0
    def test_neg_06(self):
        "TestRecordTxt2: long long line - check for multiple errors"

        tioconfig = TxtIOConfig()
        tioconfig.set_max_line_length(7)
        txt_doc = TxtRecord.from_string("""#1 com
ok: yes
 no
#4 cs
#5 dds
good: but too long
#7 dds
#8 hi
also good: but too long
#10 gsst
 dhd
#12 dhdh 
d:
#14
""", 
                                        "TooLong", tioconfig)

        assert(txt_doc.is_usable()==False)
        assert(txt_doc.to_list() ==
               [[80, MemLog.error, 'line too long: is [18], max allowed [7]', 
                 'TooLong', 6], 
                [80, MemLog.error, 'line too long: is [23], max allowed [7]', 
                 'TooLong', 9],
                [80, MemLog.error, 'line too long: is [8], max allowed [7]',
                 'TooLong', 10],
                [80, MemLog.error, 'line too long: is [9], max allowed [7]', 
                 'TooLong', 12], 
                [80, MemLog.info, TxtParser.comment_in_req, 'TooLong', 11]])
Esempio n. 7
0
    def __read(self, tname, input_handler, commit, file_info, req_set):
        '''Read in the topic and create all the tags.'''
        self.__tags = TxtRecord.from_string(file_info.get_content(), tname,
                                            input_handler.get_txt_io_config())

        for tag in self.__tags:
            # If the topic has subtopics, read them also in.
            if tag.get_tag() == "SubTopic":
                lfile_info = input_handler.get_file_info_with_type(
                    commit, "topics",
                    tag.get_content() + ".tic")
                ntopic = Topic(self.__topicset, self._config, input_handler,
                               commit, lfile_info, req_set)
                # The topic itself is already added in the constrcutor of Topic.
                # Therefore there is no need to add it here (again).
                #                self.__topicset.add_node(ntopic)
                self.__topicset.create_edge(self, ntopic)
            elif tag.get_tag() == "Name":
                if self.__topic_name != None:
                    # TODO: Multiple Names
                    assert (False)
                self.__topic_name = tag.get_content()
            elif tag.get_tag() == "IncludeRequirements":
                if tag.get_content() != "full":
                    raise RMTException(
                        113, "IncludeRequirements value not "
                        "supported [%s]" % tag.get_content(), self.get_name())
                self.__requirements = req_set.restrict_to_topics(tname)
                tracer.debug(
                    "Found [%d] requirements for topic [%s]." %
                    (self.__requirements.get_requirements_cnt(), tname))
        # Check for the existence of the name
        if self.__topic_name == None:
            raise RMTException(62, "Mandatory tag 'Name' not given in topic",
                               self.get_name())
Esempio n. 8
0
    def __read(self, tname, input_handler, commit, file_info, req_set):
        '''Read in the topic and create all the tags.'''
        Encoding.check_unicode(tname)
        self.__tags = TxtRecord.from_string(
            file_info.get_content(),
            tname, input_handler.get_txt_io_config())

        for tag in self.__tags:
            # If the topic has subtopics, read them also in.
            if tag.get_tag() == "SubTopic":
                lfile_info = input_handler.get_file_info_with_type(
                    commit, "topics", tag.get_content() + ".tic")
                ntopic = Topic(self.__digraph, self._config, input_handler,
                               commit, lfile_info, req_set)
                self.__digraph.add_node(ntopic)
                Digraph.create_edge(self, ntopic)
            elif tag.get_tag() == "Name":
                if self.__topic_name is not None:
                    # There can (currently) be only one name
                    assert False
                self.__topic_name = tag.get_content()
            elif tag.get_tag() == "IncludeRequirements":
                if tag.get_content() != "full":
                    raise RMTException(113, "IncludeRequirements value not "
                                       "supported [%s]" % tag.get_content(),
                                       self.name)
                self.__requirements = req_set.restrict_to_topics(tname)
                tracer.debug("Found [%d] requirements for topic [%s]",
                             self.__requirements.get_requirements_cnt(), tname)
        # Check for the existence of the name
        if self.__topic_name is None:
            raise RMTException(62, "Mandatory tag 'Name' not given in topic",
                               self.name)
Esempio n. 9
0
    def test_pos_01(self):
        "TestRecordTxt2: empty input"

        txt_doc = TxtRecord.from_string("", "Nothing", TxtIOConfig())

        self.assertEqual(len(txt_doc), 0)
        assert(txt_doc.get_comment() == "")
Esempio n. 10
0
    def test_neg_05(self):
        "TestRecordTxt2: long long line - check for lineno"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        cfg = Cfg.new_by_json_str('{"max_input_line_length": 7}')
        tioconfig = TxtIOConfig(cfg)
        txt_doc = TxtRecord.from_string("""# com
ok: yes
 no
# cs
# dds
good: but too long
# dds

""",
                                        "TooLong", tioconfig)

        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        
        result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;" \
        "check_line_length;77; 80:TooLong:6:line too long: is [18], " \
        "max allowed [7]\n"
        self.assertEquals(result_expected, lstderr)
Esempio n. 11
0
    def rmttest_neg_05(self):
        "TestRecordTxt2: long long line - check for lineno"
        mstderr = StringIO()
        init_logger(mstderr)

        cfg = Cfg.new_by_json_str('{"max_input_line_length": 7}')
        tioconfig = TxtIOConfig(cfg)
        txt_doc = TxtRecord.from_string(
            """# com
ok: yes
 no
# cs
# dds
good: but too long
# dds

""", "TooLong", tioconfig)

        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        result_expected \
            = "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;" \
            "check_line_length;===LINENO===; 80:TooLong:6:line too long: " \
            "is [18], max allowed [7]\n"
        self.assertEquals(result_expected, lstderr)
    def rmttest_pos_01(self):
        "TestRecordTxt2: empty input"

        txt_doc = TxtRecord.from_string("", "Nothing", TxtIOConfig())

        assert 0 == len(txt_doc)
        assert "" == txt_doc.get_comment()
Esempio n. 13
0
    def rmttest_pos_06(self):
        "Check top level Record: is_tag_available"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        txt_doc.insert(2, RecordEntry(u"Hinzu", u"This is quite new."))

        self.assertTrue(txt_doc.is_tag_available("Hinzu"))
        self.assertFalse(txt_doc.is_tag_available("NichtDa"))
Esempio n. 14
0
    def test_neg_02(self):
        "TestRecordTxt2: only ':'"

        txt_doc = TxtRecord.from_string(":", "Rubbish", TxtIOConfig())
        assert(txt_doc.is_usable()==False)
        assert(txt_doc.to_list()==
               [[79, MemLog.error, 
                 'Expected tag line not found', 'Rubbish', 1]])
Esempio n. 15
0
    def test_pos_06(self):
        "Check top level Record: is_tag_available"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        txt_doc.insert(2, RecordEntry("Hinzu", "This is quite new."))

        assert (txt_doc.is_tag_available("Hinzu"))
        assert (not txt_doc.is_tag_available("NichtDa"))
Esempio n. 16
0
    def test_pos_06(self):
        "Check top level Record: is_tag_available"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        txt_doc.insert(2, RecordEntry("Hinzu", "This is quite new."))

        assert(txt_doc.is_tag_available("Hinzu"))
        assert(not txt_doc.is_tag_available("NichtDa"))
Esempio n. 17
0
    def test_neg_08(self):
        "TestRecordTxt2: only intro content line"

        tioconfig = TxtIOConfig()
        txt_doc = TxtRecord.from_string("#1 com",
                                        "OnlyEntryComment", tioconfig)

        assert(txt_doc.is_usable()==True)
        assert(txt_doc.to_list() == [])
        assert(txt_doc.get_comment()=="1 com\n")
Esempio n. 18
0
    def test_pos_01(self):
        "Check top level RecordAsDict (string)"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        txt_doc_dict = txt_doc.get_dict()

        assert(txt_doc.get_comment() == dpC1)
        assert(txt_doc_dict["Name"].get_content() == "meiner")
        assert(txt_doc_dict["Note"].get_content() == "This is my Note.")
        assert(txt_doc.to_string()==doc1)
Esempio n. 19
0
    def test_pos_01(self):
        "Check top level RecordAsDict (string)"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        txt_doc_dict = txt_doc.get_dict()

        assert (txt_doc.get_comment() == dpC1)
        assert (txt_doc_dict["Name"].get_content() == "meiner")
        assert (txt_doc_dict["Note"].get_content() == "This is my Note.")
        assert (txt_doc.to_string() == doc1)
Esempio n. 20
0
    def test_pos_04(self):
        "Check top level Record: append entry"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        txt_doc.append(RecordEntry("Hinzu", "This is quite new."))
        txt_doc_dict = txt_doc.get_dict()

        assert(txt_doc.get_comment() == dpC1)
        assert(txt_doc_dict["Name"].get_content() == "meiner")
        assert(txt_doc_dict["Note"].get_content() == "This is my Note.")
        assert(txt_doc.to_string()==doc4)
Esempio n. 21
0
    def test_pos_04(self):
        "Check top level Record: append entry"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        txt_doc.append(RecordEntry("Hinzu", "This is quite new."))
        txt_doc_dict = txt_doc.get_dict()

        assert (txt_doc.get_comment() == dpC1)
        assert (txt_doc_dict["Name"].get_content() == "meiner")
        assert (txt_doc_dict["Note"].get_content() == "This is my Note.")
        assert (txt_doc.to_string() == doc4)
Esempio n. 22
0
    def rmttest_pos_01(self):
        "Check top level RecordAsDict (string)"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        txt_doc_dict = txt_doc.get_dict()

        self.assertEqual(dpC1, txt_doc.get_comment())
        self.assertEqual("meiner", txt_doc_dict["Name"].get_content())
        self.assertEqual("This is my Note.",
                         txt_doc_dict["Note"].get_content())
        self.assertEqual(doc1, txt_doc.to_string())
Esempio n. 23
0
    def rmttest_pos_01(self):
        "Check top level RecordAsDict (string)"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        txt_doc_dict = txt_doc.get_dict()

        assert dpC1 == txt_doc.get_comment()
        assert "meiner" == txt_doc_dict["Name"].get_content()
        assert "This is my Note." == \
            txt_doc_dict["Note"].get_content()
        assert doc1 == txt_doc.to_string()
Esempio n. 24
0
    def rmttest_pos_03(self):
        "Check top level Record: insert entry"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        txt_doc.insert(2, RecordEntry(u"Hinzu", u"This is quite new."))
        txt_doc_dict = txt_doc.get_dict()

        assert dpC1 == txt_doc.get_comment()
        assert "meiner" == txt_doc_dict["Name"].get_content()
        assert "This is my Note." == \
            txt_doc_dict["Note"].get_content()
        assert doc2 == txt_doc.to_string()
Esempio n. 25
0
    def rmttest_pos_04(self):
        "Check top level Record: append entry"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        txt_doc.append(RecordEntry(u"Hinzu", u"This is quite new."))
        txt_doc_dict = txt_doc.get_dict()

        assert dpC1 == txt_doc.get_comment()
        assert "meiner" == txt_doc_dict["Name"].get_content()
        assert "This is my Note." == \
            txt_doc_dict["Note"].get_content()
        assert doc4 == txt_doc.to_string()
Esempio n. 26
0
    def rmttest_pos_02(self):
        "Check top level RecordAsDict (fd)"

        fd = StringIO(doc1)
        txt_doc = TxtRecord.from_fd(fd, u"Nothing", TxtIOConfig())
        txt_doc_dict = txt_doc.get_dict()

        assert dpC1 == txt_doc.get_comment()
        assert "meiner" == txt_doc_dict["Name"].get_content()
        assert "This is my Note." == \
            txt_doc_dict["Note"].get_content()
        assert doc1 == txt_doc.to_string()
Esempio n. 27
0
    def test_neg_04(self):
        "TestRecordTxt2: long long line"

        tioconfig = TxtIOConfig()
        tioconfig.set_max_line_length(7)
        txt_doc = TxtRecord.from_string("good: but too long", 
                                        "TooLong", tioconfig)

        assert(txt_doc.is_usable()==False)
        assert(txt_doc.to_list() ==
               [[80, MemLog.error, 'line too long: is [18], max allowed [7]', 
                 'TooLong', 1]])
Esempio n. 28
0
    def rmttest_pos_04(self):
        "Check top level Record: append entry"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        txt_doc.append(RecordEntry(u"Hinzu", u"This is quite new."))
        txt_doc_dict = txt_doc.get_dict()

        self.assertEqual(dpC1, txt_doc.get_comment())
        self.assertEqual("meiner", txt_doc_dict["Name"].get_content())
        self.assertEqual("This is my Note.",
                         txt_doc_dict["Note"].get_content())
        self.assertEqual(doc4, txt_doc.to_string())
Esempio n. 29
0
    def test_neg_01(self):
        "TestRecordTxt2: rubbish in input"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)
        txt_doc = TxtRecord.from_string("rubbish", "Rubbish", TxtIOConfig())

        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;TxtParser;" \
        "split_entries;125; 79:Rubbish:1:Expected tag line not found\n"
        self.assertEquals(result_expected, lstderr)
Esempio n. 30
0
    def test_neg_02(self):
        "TestRecordTxt2: only ':'"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        txt_doc = TxtRecord.from_string(":", "Rubbish", TxtIOConfig())
        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        
        result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;TxtParser;" \
        "split_entries;125; 79:Rubbish:1:Expected tag line not found\n"
        self.assertEquals(result_expected, lstderr)
    def rmttest_neg_01(self):
        "TestRecordTxt2: rubbish in input"
        mstderr = StringIO()
        init_logger(mstderr)
        txt_doc = TxtRecord.from_string("rubbish", "Rubbish", TxtIOConfig())

        assert txt_doc.is_usable() is False
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()
        result_expected \
            = "===DATETIMESTAMP===;rmtoo;ERROR;TxtParser;" \
            "split_entries;===LINENO===; 79:Rubbish:1:Expected tag line " \
            "not found\n"
        assert result_expected == lstderr
Esempio n. 32
0
 def read(self):
     self.digraph.add_node(self)
     fd = file(os.path.join(self.dir, self.name + ".tic"))
     self.t = TxtRecord.from_fd(fd, self.name, 
                                self.parser_config)
     for tag in self.t:
         # If the topic has subtopics, read them also in.
         if tag.get_tag()=="SubTopic":
             ntopic = Topic(self.dir, tag.get_content(), self.digraph,
                            self.parser_config, self.level+1, self)
             #self.outgoing.append(ntopic)
             Digraph.create_edge(self, ntopic)
             #self.outgoing.append(ntopic)
     fd.close()
Esempio n. 33
0
    def rmttest_neg_08(self):
        "TestRecordTxt2: only intro content line"
        mstderr = StringIO()
        init_logger(mstderr)

        tioconfig = TxtIOConfig()
        txt_doc = TxtRecord.from_string("#1 com", "OnlyEntryComment",
                                        tioconfig)

        self.assertEqual(txt_doc.is_usable(), True)
        self.assertEqual(txt_doc.get_comment(), "1 com\n")
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        self.assertEquals("", lstderr)
Esempio n. 34
0
    def rmttest_neg_02(self):
        "TestRecordTxt2: only ':'"
        mstderr = StringIO()
        init_logger(mstderr)

        txt_doc = TxtRecord.from_string(":", "Rubbish", TxtIOConfig())
        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        result_expected \
            = "===DATETIMESTAMP===;rmtoo;ERROR;TxtParser;" \
            "split_entries;===LINENO===; 79:Rubbish:1:Expected tag line " \
            "not found\n"
        self.assertEquals(result_expected, lstderr)
Esempio n. 35
0
    def test_neg_08(self):
        "TestRecordTxt2: only intro content line"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        tioconfig = TxtIOConfig()
        txt_doc = TxtRecord.from_string("#1 com",
                                        "OnlyEntryComment", tioconfig)

        self.assertEqual(txt_doc.is_usable(), True)
        self.assertEqual(txt_doc.get_comment(), "1 com\n")
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        
        self.assertEquals("", lstderr)
Esempio n. 36
0
    def rmttest_neg_06(self):
        "TestRecordTxt2: long long line - check for multiple errors"
        mstderr = StringIO()
        init_logger(mstderr)

        cfg = Cfg.new_by_json_str('{"max_input_line_length": 7}')
        tioconfig = TxtIOConfig(cfg)
        txt_doc = TxtRecord.from_string(
            """#1 com
ok: yes
 no
#4 cs
#5 dds
good: but too long
#7 dds
#8 hi
also good: but too long
#10 gsst
 dhd
#12 dhdh
d:
#14
""", "TooLong", tioconfig)

        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        result_expected \
            = "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;" \
            "check_line_length;===LINENO===; 80:TooLong:6:line too long: " \
            "is [18], max allowed [7]\n" \
            "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;check_line_length;" \
            "===LINENO===; 80:" \
            "TooLong:9:line too long: is [23], max allowed [7]\n" \
            "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;check_line_length;" \
            "===LINENO===; 80:" \
            "TooLong:10:line too long: is [8], max allowed [7]\n" \
            "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;check_line_length;" \
            "===LINENO===; 80:" \
            "TooLong:12:line too long: is [8], max allowed [7]\n" \
            "===DATETIMESTAMP===;rmtoo;INFO;TxtParser;split_next_record;" \
            "===LINENO===; 80:" \
            "TooLong:11:Compatibility info: Comments will be reordered when " \
            "they are re-written with rmtoo-tools. Please consult " \
            "rmtoo-req-format(5) or rmtoo-topic-format(5)\n"

        self.assertEquals(result_expected, lstderr)
Esempio n. 37
0
    def rmttest_pos_05(self):
        "Check top level Record: remove entry"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        del(txt_doc[2])
        txt_doc_dict = txt_doc.get_dict()

        assert dpC1 == txt_doc.get_comment()
        assert "meiner" == txt_doc_dict["Name"].get_content()
        # 'Note' is not available - it was deleted.
        try:
            txt_doc_dict["Note"].get_content()
            assert False
        except KeyError:
            pass
        assert doc3 == txt_doc.to_string()
Esempio n. 38
0
    def test_pos_01(self):
        "TestRecordTxt3: long long complicated input"

        txt_doc = TxtRecord.from_string(tc1i, "rmtoo", TxtIOConfig())
        d = txt_doc.get_dict()

        o = StringIO.StringIO()
        txt_doc.write_log(o)

        assert(d["Rationale"].get_content() == 
               "The world needs a good, usable and free "
               "Requirements Management Tool.\par It looks "
               "that there are no such programs out.\par But: it's complex! ")

        assert(len(txt_doc)==11)
        assert(txt_doc.get_comment()=="")
Esempio n. 39
0
    def rmttest_pos_05(self):
        "Check top level Record: remove entry"

        txt_doc = TxtRecord.from_string(doc1, u"Nothing", TxtIOConfig())
        del(txt_doc[2])
        txt_doc_dict = txt_doc.get_dict()

        self.assertEqual(dpC1, txt_doc.get_comment())
        self.assertEqual("meiner", txt_doc_dict["Name"].get_content())
        # 'Note' is not available - it was deleted.
        try:
            txt_doc_dict["Note"].get_content()
            self.assertTrue(False)
        except KeyError:
            pass
        self.assertEqual(doc3, txt_doc.to_string())
Esempio n. 40
0
    def rmttest_pos_01(self):
        "TestRecordTxt3: long long complicated input"
        mstderr = StringIO()
        init_logger(mstderr)

        txt_doc = TxtRecord.from_string(tc1i, u"rmtoo", TxtIOConfig())
        d = txt_doc.get_dict()

        assert "The world needs a good, usable and free " \
            "Requirements Management Tool.\\par It looks " \
            "that there are no such programs out.\\par But: it's complex!" == \
            d["Rationale"].get_content()

        assert 11 == len(txt_doc)
        assert "" == txt_doc.get_comment()

        tear_down_log_handler()
Esempio n. 41
0
    def rmttest_pos_01(self):
        "TestRecordTxt3: long long complicated input"
        mstderr = StringIO()
        init_logger(mstderr)

        txt_doc = TxtRecord.from_string(tc1i, u"rmtoo", TxtIOConfig())
        d = txt_doc.get_dict()

        assert "The world needs a good, usable and free " \
            "Requirements Management Tool.\\par It looks " \
            "that there are no such programs out.\\par But: it's complex!" == \
            d["Rationale"].get_content()

        assert 11 == len(txt_doc)
        assert "" == txt_doc.get_comment()

        tear_down_log_handler()
Esempio n. 42
0
    def test_pos_05(self):
        "Check top level Record: remove entry"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        del(txt_doc[2])
        txt_doc_dict = txt_doc.get_dict()

        #print("ALL '%s'" % txt_doc.to_string())

        assert(txt_doc.get_comment() == dpC1)
        assert(txt_doc_dict["Name"].get_content() == "meiner")
        # 'Note' is not available - it was deleted.
        try:
            txt_doc_dict["Note"].get_content()
            assert(False)
        except KeyError, ke:
            pass
Esempio n. 43
0
    def test_pos_05(self):
        "Check top level Record: remove entry"

        txt_doc = TxtRecord.from_string(doc1, "Nothing", TxtIOConfig())
        del (txt_doc[2])
        txt_doc_dict = txt_doc.get_dict()

        #print("ALL '%s'" % txt_doc.to_string())

        assert (txt_doc.get_comment() == dpC1)
        assert (txt_doc_dict["Name"].get_content() == "meiner")
        # 'Note' is not available - it was deleted.
        try:
            txt_doc_dict["Note"].get_content()
            assert (False)
        except KeyError, ke:
            pass
Esempio n. 44
0
    def input(self, fd):
        # Read it in from the file (Syntactic input)
        self.record = TxtRecord.from_fd(fd, self.id,
                                 self.config.txtio[self.type_str])
        brmo = self.record.get_dict()
        # This 'brmo' is always valid - if there is a problem, an exception 
        # is raised.

        # Handle all the modules (Semantic input)
        self.handle_modules_tag(brmo)

        # Do not check for remaining tags here. There must be some
        # left over: all those that work on the whole requirement set
        # (e.g. 'Solved by').

        # If everything's fine, store the rest of the req for later
        # inspection.
        self.brmo = brmo
Esempio n. 45
0
    def __input(self, content):
        '''Read it in from the file (Syntactic input).'''
        txtio = TxtIOConfig(self.config, self.type_str)

        self.record = TxtRecord.from_string(content, self.id, txtio)
        brmo = self.record.get_dict()
        # This 'brmo' is always valid - if there is a problem, an exception 
        # is raised.

        # Handle all the modules (Semantic input)
        self.handle_modules_tag(brmo)

        # Do not check for remaining tags here. There must be some
        # left over: all those that work on the whole requirement set
        # (e.g. 'Solved by').

        # If everything's fine, store the rest of the req for later
        # inspection.
        self.brmo = brmo
Esempio n. 46
0
    def test_neg_06(self):
        "TestRecordTxt2: long long line - check for multiple errors"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        cfg = Cfg.new_by_json_str('{"max_input_line_length": 7}')
        tioconfig = TxtIOConfig(cfg)
        txt_doc = TxtRecord.from_string("""#1 com
ok: yes
 no
#4 cs
#5 dds
good: but too long
#7 dds
#8 hi
also good: but too long
#10 gsst
 dhd
#12 dhdh 
d:
#14
""",
                                        "TooLong", tioconfig)

        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        
        result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;" \
        "check_line_length;77; 80:TooLong:6:line too long: is [18], " \
        "max allowed [7]\n" \
        "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;check_line_length;77; 80:" \
        "TooLong:9:line too long: is [23], max allowed [7]\n" \
        "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;check_line_length;77; 80:" \
        "TooLong:10:line too long: is [8], max allowed [7]\n" \
        "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;check_line_length;77; 80:" \
        "TooLong:12:line too long: is [9], max allowed [7]\n" \
        "===DATETIMESTAMP===;rmtoo;INFO;TxtParser;split_next_record;84; 80:" \
        "TooLong:11:Compatibility info: Comments will be reordered when " \
        "they are re-written with rmtoo-tools. Please consult " \
        "rmtoo-req-format(5) or rmtoo-topic-format(5)\n"
        
        self.assertEquals(result_expected, lstderr)
Esempio n. 47
0
    def test_neg_05(self):
        "TestRecordTxt2: long long line - check for lineno"

        tioconfig = TxtIOConfig()
        tioconfig.set_max_line_length(7)
        txt_doc = TxtRecord.from_string("""# com
ok: yes
 no
# cs
# dds
good: but too long
# dds

""", 
                                        "TooLong", tioconfig)

        assert(txt_doc.is_usable()==False)
        assert([[80, MemLog.error, 'line too long: is [18], max allowed [7]',
                  'TooLong', 6]] == txt_doc.to_list())
Esempio n. 48
0
    def test_neg_04(self):
        "TestRecordTxt2: long long line"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        cfg = Cfg.new_by_json_str('{"max_input_line_length": 7}')

        tioconfig = TxtIOConfig(cfg)
        txt_doc = TxtRecord.from_string("good: but too long", "TooLong",
                                        tioconfig)

        self.assertEqual(txt_doc.is_usable(), False)
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()

        result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;" \
        "check_line_length;77; 80:TooLong:1:line too long: is [18], " \
        "max allowed [7]\n"
        self.assertEquals(result_expected, lstderr)
Esempio n. 49
0
    def __input(self, content):
        '''Read it in from the file (Syntactic input).'''
        txtio = TxtIOConfig(self.config, self.type_str)
        Encoding.check_unicode(content)
        self.record = TxtRecord.from_string(content, self._id, txtio)

        brmo = self.record.get_dict()
        # This 'brmo' is always valid - if there is a problem, an exception
        # is raised.

        # Handle all the modules (Semantic input)
        self.handle_modules_tag(brmo)

        # Do not check for remaining tags here. There must be some
        # left over: all those that work on the whole requirement set
        # (e.g. 'Solved by').

        # If everything's fine, store the rest of the req for later
        # inspection.
        self.brmo = brmo
    def rmttest_neg_04(self):
        "TestRecordTxt2: long long line"
        mstderr = StringIO()
        init_logger(mstderr)

        cfg = Cfg.new_by_json_str('{"max_input_line_length": 7}')

        tioconfig = TxtIOConfig(cfg)
        txt_doc = TxtRecord.from_string("good: but too long", "TooLong",
                                        tioconfig)

        assert txt_doc.is_usable() is False
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        result_expected \
            = "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;" \
            "check_line_length;===LINENO===; 80:TooLong:1:line too long: " \
            "is [18], max allowed [7]\n"
        assert result_expected == lstderr
Esempio n. 51
0
    def test_neg_07(self):
        "TestRecordTxt2: test comments between content lines"

        tioconfig = TxtIOConfig()
        txt_doc = TxtRecord.from_string("""#1 com
t1: uuuu
#3 Comment not allowed here.
#4 Should emitt a warning
 vvvv
t2: uuuu
 vvvv
#8 Here a comment is also not allowed
 wwww
t3: uuuu
#11 Same as t1 but with additional 
#12 comment at the end of the requirement
 vvvv
#14 End comment for t3
t4: uuuu
 vvvv
#17 Same as t2 but with additional 
#18 comment at the end of the requirement
 wwww
#20 End comment for t4
""", 
                                        "CommentsEverywhere", tioconfig)

        assert(txt_doc.is_usable()==True)

        assert(txt_doc.to_list()==
               [[80, MemLog.info, TxtParser.comment_in_req, 
                 'CommentsEverywhere', 5], 
                [80, MemLog.info, TxtParser.comment_in_req, 
                 'CommentsEverywhere', 9], 
                [80, MemLog.info, TxtParser.comment_in_req, 
                 'CommentsEverywhere', 13],
                [80, MemLog.info, TxtParser.comment_in_req, 
                 'CommentsEverywhere', 19]])
Esempio n. 52
0
    def rmttest_neg_07(self):
        "TestRecordTxt2: test comments between content lines"
        mstderr = StringIO()
        init_logger(mstderr)

        tioconfig = TxtIOConfig()
        txt_doc = TxtRecord.from_string(
            """#1 com
t1: uuuu
#3 Comment not allowed here.
#4 Should emitt a warning
 vvvv
t2: uuuu
 vvvv
#8 Here a comment is also not allowed
 wwww
t3: uuuu
#11 Same as t1 but with additional
#12 comment at the end of the requirement
 vvvv
#14 End comment for t3
t4: uuuu
 vvvv
#17 Same as t2 but with additional
#18 comment at the end of the requirement
 wwww
#20 End comment for t4
""", "CommentsEverywhere", tioconfig)

        self.assertEqual(txt_doc.is_usable(), True)
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        result_expected \
            = comment_line % 5 + comment_line % 9 + \
            comment_line % 13 + comment_line % 19

        self.assertEquals(result_expected, lstderr)
Esempio n. 53
0
    def test_neg_07(self):
        "TestRecordTxt2: test comments between content lines"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        tioconfig = TxtIOConfig()
        txt_doc = TxtRecord.from_string("""#1 com
t1: uuuu
#3 Comment not allowed here.
#4 Should emitt a warning
 vvvv
t2: uuuu
 vvvv
#8 Here a comment is also not allowed
 wwww
t3: uuuu
#11 Same as t1 but with additional 
#12 comment at the end of the requirement
 vvvv
#14 End comment for t3
t4: uuuu
 vvvv
#17 Same as t2 but with additional 
#18 comment at the end of the requirement
 wwww
#20 End comment for t4
""",
                                        "CommentsEverywhere", tioconfig)

        self.assertEqual(txt_doc.is_usable(), True)
        lstderr = hide_timestamp(mstderr.getvalue())
        tear_down_log_handler()
        
        result_expected = comment_line % 5 + comment_line % 9 + \
        comment_line % 13 + comment_line % 19
        
        self.assertEquals(result_expected, lstderr)