def test_match_is_same(self):
        r1 = Rule(text_file='r1', licenses=['apache-2.0', 'gpl'])
        m1 = LicenseMatch(rule=r1, query_position=analysis.Token(start=0, end=2))
        r2 = Rule(text_file='r2', licenses=['gpl', 'apache-2.0'])
        m2 = LicenseMatch(rule=r2, query_position=analysis.Token(start=0, end=2))

        assert m1.is_same(m2)
        assert m2.is_same(m1)
    def test_match_is_same(self):
        r1 = Rule(licenses=['apache-2.0', 'gpl'])
        m1 = LicenseMatch(rule=r1,
                          query_position=analysis.Token(start=0, end=2))
        r2 = Rule(licenses=['gpl', 'apache-2.0'])
        m2 = LicenseMatch(rule=r2,
                          query_position=analysis.Token(start=0, end=2))

        self.assertTrue(m1.is_same(m2))
        self.assertTrue(m2.is_same(m1))
    def test_match_is_not_same(self):
        r1 = Rule(text_file='r1', licenses=['apache-1.0', 'gpl'])
        m1 = LicenseMatch(rule=r1, query_position=analysis.Token(start=0, end=2))
        r2 = Rule(text_file='r2', licenses=['gpl', 'apache-2.0'])
        m2 = LicenseMatch(rule=r2, query_position=analysis.Token(start=0, end=2))

        assert not m1.is_same(m2)
        assert not m2.is_same(m1)

        r3 = Rule(text_file='r3', licenses=['apache-1.0', 'gpl'])
        m3 = LicenseMatch(rule=r3, query_position=analysis.Token(start=0, end=2))

        assert m1.is_same(m3)
        assert m3.is_same(m1)

        r4 = Rule(text_file='r4', licenses=['apache-1.0', 'gpl'])
        m4 = LicenseMatch(rule=r4, query_position=analysis.Token(start=1, end=2))

        assert not m1.is_same(m4)
        assert not m4.is_same(m1)
    def test_match_is_not_same(self):
        r1 = Rule(licenses=['apache-1.0', 'gpl'])
        m1 = LicenseMatch(rule=r1, query_position=analysis.Token(start=0, end=2))
        r2 = Rule(licenses=['gpl', 'apache-2.0'])
        m2 = LicenseMatch(rule=r2, query_position=analysis.Token(start=0, end=2))

        self.assertFalse(m1.is_same(m2))
        self.assertFalse(m2.is_same(m1))

        r3 = Rule(licenses=['apache-1.0', 'gpl'])
        m3 = LicenseMatch(rule=r3, query_position=analysis.Token(start=0, end=2))

        self.assertTrue(m1.is_same(m3))
        self.assertTrue(m3.is_same(m1))

        r4 = Rule(licenses=['apache-1.0', 'gpl'])
        m4 = LicenseMatch(rule=r4, query_position=analysis.Token(start=1, end=2))

        self.assertFalse(m1.is_same(m4))
        self.assertFalse(m4.is_same(m1))
    def test_match_is_not_same(self):
        r1 = Rule(licenses=['apache-1.0', 'gpl'])
        m1 = LicenseMatch(rule=r1,
                          query_position=analysis.Token(start=0, end=2))
        r2 = Rule(licenses=['gpl', 'apache-2.0'])
        m2 = LicenseMatch(rule=r2,
                          query_position=analysis.Token(start=0, end=2))

        self.assertFalse(m1.is_same(m2))
        self.assertFalse(m2.is_same(m1))

        r3 = Rule(licenses=['apache-1.0', 'gpl'])
        m3 = LicenseMatch(rule=r3,
                          query_position=analysis.Token(start=0, end=2))

        self.assertTrue(m1.is_same(m3))
        self.assertTrue(m3.is_same(m1))

        r4 = Rule(licenses=['apache-1.0', 'gpl'])
        m4 = LicenseMatch(rule=r4,
                          query_position=analysis.Token(start=1, end=2))

        self.assertFalse(m1.is_same(m4))
        self.assertFalse(m4.is_same(m1))
Exemple #6
0
    def test_match_is_not_same(self):
        r1 = Rule(text_file='r1', licenses=['apache-1.0', 'gpl'])
        m1 = LicenseMatch(rule=r1,
                          query_position=analysis.Token(start=0, end=2))
        r2 = Rule(text_file='r2', licenses=['gpl', 'apache-2.0'])
        m2 = LicenseMatch(rule=r2,
                          query_position=analysis.Token(start=0, end=2))

        assert not m1.is_same(m2)
        assert not m2.is_same(m1)

        r3 = Rule(text_file='r3', licenses=['apache-1.0', 'gpl'])
        m3 = LicenseMatch(rule=r3,
                          query_position=analysis.Token(start=0, end=2))

        assert m1.is_same(m3)
        assert m3.is_same(m1)

        r4 = Rule(text_file='r4', licenses=['apache-1.0', 'gpl'])
        m4 = LicenseMatch(rule=r4,
                          query_position=analysis.Token(start=1, end=2))

        assert not m1.is_same(m4)
        assert not m4.is_same(m1)