Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Nov 13, 2019
1 parent 674a174 commit b7053dc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_nvti_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

from unittest import TestCase
from unittest.mock import patch

from ospd_openvas.db import OpenvasDB

from ospd_openvas import nvticache
from ospd_openvas.nvticache import NVTICache


Expand Down Expand Up @@ -270,3 +273,15 @@ def test_get_nvt_tag(self, mock_redis):
resp = self.nvti.get_nvt_tag(mock_redis(), '1.2.3.4')

self.assertEqual(out_dict, resp)

@patch('ospd_openvas.nvticache.subprocess')
def test_set_nvticache_str(self, mock_subps, mock_redis):
self.assertIsNone(self.nvti.NVTICACHE_STR)

mock_subps.check_output.return_value = '20.10\n'.encode()
self.nvti.set_nvticache_str()
self.assertEqual(self.nvti.NVTICACHE_STR, 'nvticache20.10')

mock_subps.check_output.return_value = '11.0.1\n'.encode()
with self.assertRaises(SystemExit):
self.nvti.set_nvticache_str()

0 comments on commit b7053dc

Please sign in to comment.