def test_combine_raise_TypeError_for_matches_of_different_rules(self): r1 = Rule(text_file='r1', license_expression='apache-2.0 OR gpl') r2 = Rule(text_file='r2', license_expression='apache-2.0 OR gpl2') m1 = LicenseMatch(rule=r1, qspan=Span(0, 5), ispan=Span(0, 5)) m2 = LicenseMatch(rule=r2, qspan=Span(1, 6), ispan=Span(1, 6)) try: m1.combine(m2) except TypeError: pass
def test_combine_raise_TypeError_for_matches_of_different_rules(self): r1 = Rule(text_file='r1', licenses=['apache-2.0', 'gpl']) r2 = Rule(text_file='r2', licenses=['apache-2.0', 'gpl2']) m1 = LicenseMatch(rule=r1, qspan=Span(0, 5), ispan=Span(0, 5)) m2 = LicenseMatch(rule=r2, qspan=Span(1, 6), ispan=Span(1, 6)) try: m1.combine(m2) except TypeError: pass
def test_combine_matches_cannot_combine_matches_with_same_licensing_and_different_rules(self): r1 = Rule(text_file='r1', licenses=['apache-2.0', 'gpl']) r2 = Rule(text_file='r2', licenses=['apache-2.0', 'gpl']) m1 = LicenseMatch(rule=r1, qspan=Span(0, 5), ispan=Span(0, 5)) m2 = LicenseMatch(rule=r2, qspan=Span(1, 6), ispan=Span(1, 6)) try: m1.combine(m2) self.fail('Should fail') except TypeError: pass
def test_combine_matches_with_same_rules(self): r1 = Rule(text_file='r1', license_expression='apache-2.0 OR gpl') m1 = LicenseMatch(rule=r1, qspan=Span(0, 5), ispan=Span(0, 5)) m2 = LicenseMatch(rule=r1, qspan=Span(1, 6), ispan=Span(1, 6)) match = m1.combine(m2) assert Span(0, 6) == match.qspan assert Span(0, 6) == match.ispan
def test_combine_matches_with_same_rules(self): r1 = Rule(text_file='r1', licenses=['apache-2.0', 'gpl']) m1 = LicenseMatch(rule=r1, qspan=Span(0, 5), ispan=Span(0, 5)) m2 = LicenseMatch(rule=r1, qspan=Span(1, 6), ispan=Span(1, 6)) match = m1.combine(m2) assert Span(0, 6) == match.qspan assert Span(0, 6) == match.ispan