Coverage for tests / integration / tools / osv_scanner / test_options.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Integration tests for OsvScannerPlugin.set_options method.""" 

2 

3from __future__ import annotations 

4 

5import shutil 

6from collections.abc import Callable 

7from typing import TYPE_CHECKING 

8 

9import pytest 

10from assertpy import assert_that 

11 

12if TYPE_CHECKING: 

13 from lintro.plugins.base import BaseToolPlugin 

14 

15# Skip all tests if osv-scanner is not installed 

16pytestmark = pytest.mark.skipif( 

17 shutil.which("osv-scanner") is None, 

18 reason="osv-scanner not installed", 

19) 

20 

21 

22@pytest.mark.parametrize( 

23 ("option_name", "option_value", "expected"), 

24 [ 

25 ("timeout", 30, 30), 

26 ("timeout", 60, 60), 

27 ("timeout", 300, 300), 

28 ], 

29 ids=["timeout_30", "timeout_60", "timeout_300"], 

30) 

31def test_set_options_timeout( 

32 get_plugin: Callable[[str], BaseToolPlugin], 

33 option_name: str, 

34 option_value: object, 

35 expected: object, 

36) -> None: 

37 """Verify OsvScannerPlugin.set_options correctly sets timeout.""" 

38 plugin = get_plugin("osv_scanner") 

39 plugin.set_options(**{option_name: option_value}) 

40 assert_that(plugin.options.get(option_name)).is_equal_to(expected) 

41 

42 

43def test_invalid_timeout( 

44 get_plugin: Callable[[str], BaseToolPlugin], 

45) -> None: 

46 """Verify OsvScannerPlugin.set_options rejects invalid timeout values.""" 

47 plugin = get_plugin("osv_scanner") 

48 with pytest.raises(ValueError, match="must be positive"): 

49 plugin.set_options(timeout=-1)