Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/lib/sift_client/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ select = [
"LOG", # flake8-logging - logging best practices

# Tests
# "PT", # flake8-pytest-style - pytest best practices # TODO: FD-59
"PT", # flake8-pytest-style - pytest best practices

]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_calculated_channel(calculated_channels_api_sync):
return calculated_channels[0]


@pytest.fixture(scope="function")
Comment thread
ian-sift marked this conversation as resolved.
@pytest.fixture
def new_calculated_channel(calculated_channels_api_sync, sift_client):
"""Create a test calculated channel for update tests."""
from datetime import datetime, timezone
Expand Down Expand Up @@ -450,7 +450,9 @@ async def test_update_with_invalid_expression(
assert updated_calc_channel.expression == "invalid_expression"
except Exception as e:
# If server validates and rejects, that's also acceptable behavior
assert "expression" in str(e).lower() or "invalid" in str(e).lower()
assert ( # noqa: PT017
"expression" in str(e).lower() or "invalid" in str(e).lower()
)
finally:
await calculated_channels_api_async.archive(new_calculated_channel.id_)

Expand Down
2 changes: 1 addition & 1 deletion python/lib/sift_client/_tests/resources/test_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_client_binding(sift_client):
assert sift_client.async_.ingestion


@pytest.fixture(scope="function")
@pytest.fixture
def test_run(sift_client: SiftClient):
"""Create a test run for ingestion tests."""
run = sift_client.runs.create(
Expand Down
2 changes: 1 addition & 1 deletion python/lib/sift_client/_tests/resources/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def test_archive_and_delete_test_report(self, sift_client):
assert deleted_report is None # Shouldn't reach here so error if we get something.
except aiogrpc.AioRpcError as e:
self.test_reports.pop("basic_test_report")
assert e.code() == grpc.StatusCode.NOT_FOUND
assert e.code() == grpc.StatusCode.NOT_FOUND # noqa: PT017

def test_import_test_report(self, sift_client):
# Import a test report from a file
Expand Down
6 changes: 4 additions & 2 deletions python/lib/sift_client/_tests/resources/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_rule(rules_api_sync):
return rules[0]


@pytest.fixture(scope="function")
@pytest.fixture
def new_rule(rules_api_sync, sift_client):
"""Create a test rule for update tests."""
from datetime import datetime, timezone
Expand Down Expand Up @@ -558,7 +558,9 @@ async def test_update_with_invalid_expression(self, rules_api_async, new_rule):
assert updated_rule.expression == "invalid_expression"
except Exception as e:
# If server validates and rejects, that's also acceptable behavior
assert "expression" in str(e).lower() or "invalid" in str(e).lower()
assert ( # noqa: PT017
"expression" in str(e).lower() or "invalid" in str(e).lower()
)
finally:
await rules_api_async.archive(new_rule.id_)

Expand Down
2 changes: 1 addition & 1 deletion python/lib/sift_client/_tests/resources/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_run(runs_api_sync):
return runs[0]


@pytest.fixture(scope="function")
@pytest.fixture
def new_run(runs_api_sync):
"""Create a test run for update tests."""
run_name = f"test_run_update_{datetime.now(timezone.utc).isoformat()}"
Expand Down
18 changes: 9 additions & 9 deletions python/lib/sift_client/_tests/sift_types/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,18 @@ def test_multiple_nested_fields_same_parent(self):

def test_validation_error_on_invalid_helper_field(self):
"""Test that MappingHelper validation catches mismatched fields."""
with pytest.raises(ValueError, match="MappingHelper created for"):

class InvalidModel(ModelCreate[CreateCalculatedChannelRequest]):
name: str
class InvalidModel(ModelCreate[CreateCalculatedChannelRequest]):
name: str

_to_proto_helpers: ClassVar[dict[str, MappingHelper]] = {
"nonexistent_field": MappingHelper(proto_attr_path="some.path"),
}
_to_proto_helpers: ClassVar[dict[str, MappingHelper]] = {
"nonexistent_field": MappingHelper(proto_attr_path="some.path"),
}

def _get_proto_class(self):
return CreateCalculatedChannelRequest
def _get_proto_class(self):
return CreateCalculatedChannelRequest

with pytest.raises(ValueError, match="MappingHelper created for"):
# This should raise during __init__
InvalidModel(name="test")

Expand Down Expand Up @@ -495,7 +495,7 @@ def _from_proto(cls, proto, sift_client=None):
model = TestModel(name="test")

# Should not be able to modify frozen model
with pytest.raises(Exception): # Pydantic raises ValidationError # noqa: B017
with pytest.raises(Exception): # noqa: B017, PT011
model.name = "new_name"


Expand Down
Loading