Ejemplo n.º 1
0
    def test_throws_errors(self, incr_mock, yara_compile_mock):
        yara_compile_mock.side_effect = Exception()

        # We use `_run_yara()` because `run_yara()` is decorated with
        # `@validation_task`, which gracefully handles exceptions.
        with self.assertRaises(Exception):
            _run_yara(self.results, self.upload.pk)

        assert incr_mock.called
        incr_mock.assert_called_with('devhub.yara.failure')
Ejemplo n.º 2
0
    def test_run_does_not_raise(self, incr_mock, yara_compile_mock):
        self.create_switch('ignore-exceptions-in-scanner-tasks', active=True)
        yara_compile_mock.side_effect = Exception()

        # We use `_run_yara()` because `run_yara()` is decorated with
        # `@validation_task`, which gracefully handles exceptions.
        received_results = _run_yara(self.results, self.upload.pk)

        assert incr_mock.called
        incr_mock.assert_called_with('devhub.yara.failure')
        # The task should always return the results.
        assert received_results == self.results