-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_toolset.py
More file actions
75 lines (53 loc) · 3.01 KB
/
test_toolset.py
File metadata and controls
75 lines (53 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""Tests for StackOneToolSet."""
from stackone_ai.toolset import StackOneToolSet
def test_set_accounts():
"""Test setting account IDs for filtering"""
toolset = StackOneToolSet(api_key="test_key")
result = toolset.set_accounts(["acc1", "acc2"])
# Should return self for chaining
assert result is toolset
assert toolset._account_ids == ["acc1", "acc2"]
def test_filter_by_provider():
"""Test provider filtering"""
toolset = StackOneToolSet(api_key="test_key")
# Test matching providers
assert toolset._filter_by_provider("hibob_list_employees", ["hibob", "bamboohr"])
assert toolset._filter_by_provider("bamboohr_create_job", ["hibob", "bamboohr"])
# Test non-matching providers
assert not toolset._filter_by_provider("workday_list_contacts", ["hibob", "bamboohr"])
# Test case-insensitive matching
assert toolset._filter_by_provider("HIBOB_list_employees", ["hibob"])
assert toolset._filter_by_provider("hibob_list_employees", ["HIBOB"])
def test_filter_by_action():
"""Test action filtering with glob patterns"""
toolset = StackOneToolSet(api_key="test_key")
# Test exact match
assert toolset._filter_by_action("hibob_list_employees", ["hibob_list_employees"])
# Test glob pattern
assert toolset._filter_by_action("hibob_list_employees", ["*_list_employees"])
assert toolset._filter_by_action("bamboohr_list_employees", ["*_list_employees"])
assert toolset._filter_by_action("hibob_list_employees", ["hibob_*"])
assert toolset._filter_by_action("hibob_create_employee", ["hibob_*"])
# Test non-matching patterns
assert not toolset._filter_by_action("workday_list_contacts", ["*_list_employees"])
assert not toolset._filter_by_action("bamboohr_create_job", ["hibob_*"])
def test_matches_filter_positive_patterns():
"""Test _matches_filter with positive patterns"""
toolset = StackOneToolSet(api_key="test_key")
# Single pattern
assert toolset._matches_filter("hibob_list_employees", "hibob_*")
assert toolset._matches_filter("bamboohr_create_job", "bamboohr_*")
assert not toolset._matches_filter("workday_contacts", "hibob_*")
# Multiple patterns (OR logic)
assert toolset._matches_filter("hibob_list_employees", ["hibob_*", "bamboohr_*"])
assert toolset._matches_filter("bamboohr_create_job", ["hibob_*", "bamboohr_*"])
assert not toolset._matches_filter("workday_contacts", ["hibob_*", "bamboohr_*"])
def test_matches_filter_negative_patterns():
"""Test _matches_filter with negative patterns (exclusion)"""
toolset = StackOneToolSet(api_key="test_key")
# Negative pattern
assert not toolset._matches_filter("hibob_delete_employee", ["hibob_*", "!hibob_delete_*"])
assert toolset._matches_filter("hibob_list_employees", ["hibob_*", "!hibob_delete_*"])
# Only negative patterns (should match everything not excluded)
assert not toolset._matches_filter("hibob_delete_employee", "!hibob_delete_*")
assert toolset._matches_filter("hibob_list_employees", "!hibob_delete_*")