def test_get_key_count_with_default_pattern(self, mock_redis): ctx = mock_redis.return_value ctx.keys.return_value = ['aa', 'ab'] ret = OpenvasDB.get_key_count(ctx) self.assertEqual(ret, 2) ctx.keys.assert_called_with('*')
def test_get_key_count(self, mock_redis): ctx = mock_redis.return_value ctx.keys.return_value = ['aa', 'ab'] ret = OpenvasDB.get_key_count(ctx, "foo") self.assertEqual(ret, 2) ctx.keys.assert_called_with('foo')
def test_get_key_count_error(self, mock_redis): with self.assertRaises(RequiredArgument): OpenvasDB.get_key_count(None)
def get_nvt_count(self) -> int: return OpenvasDB.get_key_count(self.ctx, "nvt:*")
def get_nvt_files_count(self) -> int: return OpenvasDB.get_key_count(self.ctx, "filename:*")