Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    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])
Ejemplo n.º 4
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)