Skip to content

Commit 863fc37

Browse files
committed
update tests
1 parent ed569e3 commit 863fc37

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/unit/common/test_helper_functions.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4+
from unittest.mock import patch
5+
46
from pyrit.common.utils import combine_dict, select_word_indices
57

68

@@ -36,5 +38,12 @@ def test_combine_dict_same_keys():
3638

3739
def test_word_indices_selection():
3840
assert select_word_indices(words=["word1", "word2", "word3"], mode="all") == [0, 1, 2]
41+
assert select_word_indices(words=["word1", "word2", "word3"], mode="custom", indices=[0, 2]) == [0, 2]
3942
assert select_word_indices(words=["word1", "word2", "pyrit", "word4"], mode="keywords", keywords=["pyrit"]) == [2]
4043
assert select_word_indices(words=["word1", "word2", "pyrit", "word4"], mode="regex", regex=r"word\d") == [0, 1, 3]
44+
45+
with patch("random.sample", return_value=[0, 2]):
46+
result = select_word_indices(words=["word1", "word2", "word3", "word4"], mode="random", sample_ratio=0.5)
47+
assert result == [0, 2]
48+
49+
assert select_word_indices(words=["word1", "word2"], mode="invalid_mode") == [0, 1]

0 commit comments

Comments
 (0)