def test_analyze_error(self):
        """Test whether an exception is thrown in case of error"""

        scancode_cli = ScanCode(exec_path=SCANCODE_CLI_PATH, cli=True)
        kwargs = {'file_paths': os.path.join(self.tmp_data_path, ANALYZER_TEST_FILE)}
        with self.assertRaises(GraalError):
            _ = scancode_cli.analyze(**kwargs)
    def test_init(self):
        """Test the analyzer is properly initialized"""

        scancode_cli = ScanCode(exec_path=SCANCODE_CLI_PATH)
        self.assertEqual(scancode_cli.exec_path, SCANCODE_CLI_PATH)

        with self.assertRaises(GraalError):
            _ = ScanCode("/tmp/invalid")
Esempio n. 3
0
 def __init__(self, exec_path, kind=NOMOS):
     self.kind = kind
     if kind == SCANCODE:
         self.analyzer = ScanCode(exec_path)
     elif kind == SCANCODE_CLI:
         self.analyzer = ScanCode(exec_path, cli=True)
     else:
         self.analyzer = Nomos(exec_path)
Esempio n. 4
0
    def test_analyze(self):
        """Test whether nomos returns the expected fields data"""

        scancode = ScanCode(exec_path=SCANCODE_PATH)
        kwargs = {'file_path': os.path.join(self.tmp_data_path, ANALYZER_TEST_FILE)}
        result = scancode.analyze(**kwargs)

        self.assertIn('licenses', result)
    def test_analyze_scancode_cli(self):
        """Test whether scancode_cli returns the expected fields data"""

        scancode_cli = ScanCode(exec_path=SCANCODE_CLI_PATH, cli=True)
        kwargs = {'file_paths': [os.path.join(self.tmp_data_path, ANALYZER_TEST_FILE)]}
        result = scancode_cli.analyze(**kwargs)

        self.assertIn('licenses', result['files'][0])
Esempio n. 6
0
    def test_analyze_error(self, check_output_mock):
        """Test whether an exception is thrown in case of errors"""

        check_output_mock.side_effect = subprocess.CalledProcessError(-1, "command", output=b'output')

        scancode = ScanCode(exec_path=SCANCODE_PATH)
        kwargs = {'file_path': os.path.join(self.tmp_data_path, ANALYZER_TEST_FILE)}
        with self.assertRaises(GraalError):
            _ = scancode.analyze(**kwargs)
Esempio n. 7
0
 def __init__(self, exec_path, kind=NOMOS):
     if kind == SCANCODE:
         self.analyzer = ScanCode(exec_path)
     else:
         self.analyzer = Nomos(exec_path)