Skip to content

Commit 1f70267

Browse files
committed
test(LAB-4081): add unit tests for "is not" operator filters in assets domain API
1 parent 337d45c commit 1f70267

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

tests/unit/domain_api/test_assets.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,90 @@ def test_list_assets_as_list(self, assets_namespace):
109109
assert call_kwargs["project_id"] == "project_123"
110110
assert call_kwargs["as_generator"] is False
111111

112+
def test_list_assets_with_status_not_in_filter(self, assets_namespace):
113+
"""Test list method with status_not_in filter."""
114+
# Mock the legacy client method
115+
assets_namespace._client.assets.return_value = [
116+
{"id": "asset1", "externalId": "ext1", "status": "LABELED"},
117+
]
118+
119+
result = assets_namespace.list(
120+
project_id="project_123", filter={"status_not_in": ["TODO", "ONGOING"]}
121+
)
122+
123+
# Verify the legacy method was called with the filter
124+
assets_namespace._client.assets.assert_called_once()
125+
call_kwargs = assets_namespace._client.assets.call_args[1]
126+
assert call_kwargs["status_not_in"] == ["TODO", "ONGOING"]
127+
128+
def test_list_assets_with_step_status_not_in_filter(self, assets_namespace):
129+
"""Test list method with step_status_not_in filter."""
130+
# Mock the legacy client method
131+
assets_namespace._client.assets.return_value = [
132+
{"id": "asset1", "externalId": "ext1"},
133+
]
134+
135+
result = assets_namespace.list(
136+
project_id="project_123", filter={"step_status_not_in": ["DONE", "SKIPPED"]}
137+
)
138+
139+
# Verify the legacy method was called with the filter
140+
assets_namespace._client.assets.assert_called_once()
141+
call_kwargs = assets_namespace._client.assets.call_args[1]
142+
assert call_kwargs["step_status_not_in"] == ["DONE", "SKIPPED"]
143+
144+
def test_list_assets_with_step_name_not_in_filter(self, assets_namespace):
145+
"""Test list method with step_name_not_in filter."""
146+
# Mock the legacy client method
147+
assets_namespace._client.assets.return_value = [
148+
{"id": "asset1", "externalId": "ext1"},
149+
]
150+
151+
result = assets_namespace.list(
152+
project_id="project_123", filter={"step_name_not_in": ["Review", "QA"]}
153+
)
154+
155+
# Verify the legacy method was called with the filter
156+
assets_namespace._client.assets.assert_called_once()
157+
call_kwargs = assets_namespace._client.assets.call_args[1]
158+
assert call_kwargs["step_name_not_in"] == ["Review", "QA"]
159+
160+
def test_count_assets_with_status_not_in_filter(self, assets_namespace):
161+
"""Test count method with status_not_in filter."""
162+
# Mock the legacy client method
163+
assets_namespace._client.count_assets.return_value = 42
164+
165+
result = assets_namespace.count(
166+
project_id="project_123", filter={"status_not_in": ["REVIEWED"]}
167+
)
168+
169+
# Verify the result
170+
assert result == 42
171+
172+
# Verify the legacy method was called with the filter
173+
assets_namespace._client.count_assets.assert_called_once()
174+
call_kwargs = assets_namespace._client.count_assets.call_args[1]
175+
assert call_kwargs["status_not_in"] == ["REVIEWED"]
176+
177+
def test_count_assets_with_step_filters_not_in(self, assets_namespace):
178+
"""Test count method with step_status_not_in and step_name_not_in filters."""
179+
# Mock the legacy client method
180+
assets_namespace._client.count_assets.return_value = 15
181+
182+
result = assets_namespace.count(
183+
project_id="project_123",
184+
filter={"step_status_not_in": ["DONE"], "step_name_not_in": ["Final Review"]},
185+
)
186+
187+
# Verify the result
188+
assert result == 15
189+
190+
# Verify the legacy method was called with both filters
191+
assets_namespace._client.count_assets.assert_called_once()
192+
call_kwargs = assets_namespace._client.count_assets.call_args[1]
193+
assert call_kwargs["step_status_not_in"] == ["DONE"]
194+
assert call_kwargs["step_name_not_in"] == ["Final Review"]
195+
112196
def test_count_assets(self, assets_namespace):
113197
"""Test count method."""
114198
# Mock the legacy client method

0 commit comments

Comments
 (0)