예제 #1
0
    def test_load(self):
        self.write_run_file({"result": "success", "runtime": "23.42", "message": "-arbitrary text-"})

        execution = MineAndDetectExecution(self.detector, self.version, self.findings_path, AllFindings(self.detector))

        assert execution.is_success()
        assert_equals(execution.runtime, "23.42")
        assert_equals(execution.message, "-arbitrary text-")
예제 #2
0
class TestMineAndDetectExecution:
    # noinspection PyAttributeOutsideInit
    def setup(self):
        self.version = create_version("-version-", project=create_project("-project-"))
        self.detector = Dummy("-detectors-")
        self.findings_base_path = "-findings-"

        self.logger = logging.getLogger("test")

        self.__orig_shell_exec = Shell.exec
        Shell.exec = MagicMock()

        self.uut = MineAndDetectExecution(
            self.detector, self.version, self.findings_base_path, AllFindings(self.detector)
        )
        self.uut.save = MagicMock

    def teardown(self):
        Shell.exec = self.__orig_shell_exec

    def test_execute(self):
        jar = join("-detectors-", "Dummy", "Dummy.jar")
        target = join("-findings-", "mine_and_detect", "Dummy", "-project-", "-version-", "findings.yml")
        run_info = join("-findings-", "mine_and_detect", "Dummy", "-project-", "-version-", "run.yml")
        target_src_path = join("-compiles-", "-project-", "-version-", "original-src")
        target_classpath = join("-compiles-", "-project-", "-version-", "original-classes")

        self.uut.execute("-compiles-", 42, self.logger)

        Shell.exec.assert_called_with(
            'java -jar "{}" '.format(jar)
            + 'target "{}" '.format(target)
            + 'run_info "{}" '.format(run_info)
            + 'detector_mode "0" '
            + 'target_src_path "{}" '.format(target_src_path)
            + 'target_classpath "{}"'.format(target_classpath),
            logger=self.logger,
            timeout=42,
        )
예제 #3
0
    def setup(self):
        self.version = create_version("-version-", project=create_project("-project-"))
        self.detector = Dummy("-detectors-")
        self.findings_base_path = "-findings-"

        self.logger = logging.getLogger("test")

        self.__orig_shell_exec = Shell.exec
        Shell.exec = MagicMock()

        self.uut = MineAndDetectExecution(
            self.detector, self.version, self.findings_base_path, AllFindings(self.detector)
        )
        self.uut.save = MagicMock