コード例 #1
0
 def test_spdxrule_with_invalid_expression(self):
     try:
         models.SpdxRule(
             license_expression='mit OR gpl-2.0 AND',
             stored_text='mit OR gpl-2.0',
             length=12,
         )
     except Exception as e:
         assert 'Unable to parse License rule expression: ' in str(e)
コード例 #2
0
 def test_spdxrule_with_invalid_expression(self):
     try:
         models.SpdxRule(
             license_expression='mit OR gpl-2.0 AND',
             stored_text='mit OR gpl-2.0',
             length=12,
         )
     except Exception as e:
         ex = str(e)
         assert 'Unable to parse License rule expression: ' in ex
         assert 'ExpressionError: AND requires two or more licenses as in: MIT AND BSD' in ex
コード例 #3
0
    def test_spdxrule(self):
        rule = models.SpdxRule(
            license_expression='mit OR gpl-2.0',
            stored_text='mit OR gpl-2.0',
            length=12,
        )
        try:
            rule.dump()
            raise Exception('SpdxRule cannot be dumped')
        except NotImplementedError:
            pass

        try:
            rule.load()
            raise Exception('SpdxRule cannot be dumped')
        except NotImplementedError:
            pass

        assert not rule.is_small
        assert rule.relevance == 100