def test3get_match_element_valid_match(self):
     """Parse matching substring from MatchContext and check if the MatchContext was updated with all characters."""
     data = b"fixed data string."
     value = self.fixed_data
     match_context = DummyMatchContext(data)
     fixed_dme = DummyFixedDataModelElement(self.fixed_id, self.fixed_data)
     optional_match = OptionalMatchModelElement(self.id_, fixed_dme)
     match_element = optional_match.get_match_element(
         self.path, match_context)
     self.compare_match_results(
         data, match_element, match_context, self.id_, self.path, value,
         value, [
             fixed_dme.get_match_element("%s/%s" % (self.path, self.id_),
                                         DummyMatchContext(data))
         ])
    def test3get_match_element_valid_match(self):
        """Parse matching substring from MatchContext and check if the MatchContext was updated with all characters."""
        fixed_dme = DummyFixedDataModelElement(self.fixed_id, self.fixed_data)
        repeated_dme = RepeatedElementDataModelElement(
            self.id_, DummyFixedDataModelElement(self.fixed_id,
                                                 self.fixed_data))
        data = b"fixed data string."
        value = b"fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, value,
            value, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])

        data = b"fixed data fixed data fixed data fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, data,
            data, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/1" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/2" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/3" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])

        data = b"fixed data fixed data \nhere is some other string.\nfixed data fixed data "
        value = b"fixed data fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, value,
            value, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/1" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])
    def test4get_match_element_min_max_repeats(self):
        """This test case verifies the functionality of setting the minimal and maximal repeats."""
        fixed_dme = DummyFixedDataModelElement(self.fixed_id, self.fixed_data)
        repeated_dme = RepeatedElementDataModelElement(self.id_,
                                                       fixed_dme,
                                                       min_repeat=2,
                                                       max_repeat=5)
        same_min_max_repeat_dme = RepeatedElementDataModelElement(self.id_,
                                                                  fixed_dme,
                                                                  min_repeat=3,
                                                                  max_repeat=3)
        data = b"other data"
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_no_match_results(data, match_element, match_context)
        match_context = DummyMatchContext(data)
        match_element = same_min_max_repeat_dme.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_no_match_results(data, match_element, match_context)

        match_context = DummyMatchContext(data)
        match_element = same_min_max_repeat_dme.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"fixed data fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, data,
            data, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/1" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])

        match_context = DummyMatchContext(data)
        match_element = same_min_max_repeat_dme.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"fixed data fixed data fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, data,
            data, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/1" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/2" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])

        match_context = DummyMatchContext(data)
        match_element = same_min_max_repeat_dme.get_match_element(
            self.path, match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, data,
            data, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/1" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/2" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])

        data = b"fixed data fixed data fixed data fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, data,
            data, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/1" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/2" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/3" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])

        match_context = DummyMatchContext(data)
        match_element = same_min_max_repeat_dme.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"fixed data fixed data fixed data fixed data fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_match_results(
            data, match_element, match_context, self.id_, self.path, data,
            data, [
                fixed_dme.get_match_element("%s/%s/0" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/1" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/2" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/3" % (self.path, self.id_),
                                            DummyMatchContext(data)),
                fixed_dme.get_match_element("%s/%s/4" % (self.path, self.id_),
                                            DummyMatchContext(data))
            ])

        match_context = DummyMatchContext(data)
        match_element = same_min_max_repeat_dme.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"fixed data fixed data fixed data fixed data fixed data fixed data "
        match_context = DummyMatchContext(data)
        match_element = repeated_dme.get_match_element(self.path,
                                                       match_context)
        self.compare_no_match_results(data, match_element, match_context)

        match_context = DummyMatchContext(data)
        match_element = same_min_max_repeat_dme.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)