Skip to content

Conversation

Copy link

Copilot AI commented Oct 16, 2025

Problem

showed many uncovered lines in openfga_sdk/client/models/write_options.py and its related dependency files (write_transaction_opts.py and write_conflict_opts.py). Additionally, several write request model files lacked test coverage.

Solution

Created a comprehensive test suite that provides maximum coverage for all targeted model files:

  • test/client/models/write_options_test.py - 36 test cases
  • test/client/models/write_request_test.py - 22 test cases
  • test/models/write_request_deletes_test.py - 22 test cases
  • test/models/write_request_writes_test.py - 22 test cases

Coverage Details

ClientWriteOptions (11 tests)

Tests all initialization scenarios, property getters, and setters:

# Constructor with various parameter combinations
options = ClientWriteOptions()
options = ClientWriteOptions(authorization_model_id="01HVMMBCMGZNT3SED4Z17ECXCA")
options = ClientWriteOptions(transaction=WriteTransactionOpts())
options = ClientWriteOptions(conflict=ConflictOptions())

# Property setters including None values
options.authorization_model_id = "model_id"
options.transaction = None

WriteTransactionOpts (9 tests)

Tests default values, custom initialization, and all property setters:

opts = WriteTransactionOpts()  # Default: disabled=False, max_per_chunk=1, max_parallel_requests=10
opts = WriteTransactionOpts(disabled=True, max_per_chunk=15, max_parallel_requests=25)
opts.disabled = True
opts.max_per_chunk = 10

ConflictOptions (16 tests)

Tests initialization with enum values and all property combinations:

opts = ConflictOptions(on_duplicate_writes=ClientWriteRequestOnDuplicateWrites.ERROR)
opts = ConflictOptions(on_missing_deletes=ClientWriteRequestOnMissingDeletes.IGNORE)
opts.on_duplicate_writes = None

ClientWriteRequest (22 tests)

Tests initialization, property getters/setters, and tuple key conversion methods:

# Various initialization scenarios
request = ClientWriteRequest(writes=[...], deletes=[...], on_duplicate="error", on_missing="error")

# Tuple key conversion methods
writes_tuple_keys = request.writes_tuple_keys  # Returns WriteRequestWrites
deletes_tuple_keys = request.deletes_tuple_keys  # Returns WriteRequestDeletes

WriteRequestDeletes (22 tests)

Tests initialization, validation, setters, and utility methods:

# Initialization with validation
deletes = WriteRequestDeletes(tuple_keys=[...], on_missing="error")

# Validation raises ValueError for invalid values
deletes.on_missing = "invalid"  # Raises ValueError

# Utility methods
deletes.to_dict()
deletes == other_deletes

WriteRequestWrites (22 tests)

Tests initialization, validation, setters, and utility methods:

# Initialization with validation
writes = WriteRequestWrites(tuple_keys=[...], on_duplicate="ignore")

# Validation raises ValueError for invalid values
writes.on_duplicate = "invalid"  # Raises ValueError

# Utility methods
writes.to_dict()
writes == other_writes

Test Results

  • ✅ All 102 tests pass successfully
  • ✅ Maximum line coverage for all targeted model files
  • ✅ No regressions in existing tests
  • ✅ Follows existing unittest patterns in the repository

The test suite covers all constructors, property getters, property setters, enum values, validation logic, utility methods (to_dict, eq, ne), and edge cases including None values.

Original prompt

There are many uncovered lines in the patch in this https://app.codecov.io/gh/openfga/python-sdk/pull/237?src=pr&el=tree&filepath=openfga_sdk%2Fclient%2Fmodels%2Fwrite_options.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openfga#diff-b3BlbmZnYV9zZGsvY2xpZW50L21vZGVscy93cml0ZV9vcHRpb25zLnB5

Accordingly add test cases to ensure maximum test coverage


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add test cases to improve coverage in write_options.py Add comprehensive test coverage for write_options.py and related models Oct 16, 2025
Copilot AI requested a review from SoulPancake October 16, 2025 09:28
Copilot finished work on behalf of SoulPancake October 16, 2025 09:28
Copy link
Author

Copilot AI commented Oct 16, 2025

@copilot Also write tests for these

openfga_sdk/client/models/write_request.py
...

Added comprehensive test coverage for the requested files:

  • openfga_sdk/client/models/write_request.py - 22 tests
  • openfga_sdk/models/write_request_deletes.py - 22 tests
  • openfga_sdk/models/write_request_writes.py - 22 tests

All 66 new tests are passing. The tests cover initialization, property getters/setters, validation, and utility methods like to_dict, eq, and ne.

Note: openfga_sdk/client/models/write_conflict_opts.py already has comprehensive test coverage from the initial PR (included in write_options_test.py).

Commit: f16cfb8 (original), plus this commit for the additional models.

Copilot AI changed the title Add comprehensive test coverage for write_options.py and related models Add comprehensive test coverage for write_options.py and related write request models Oct 16, 2025
Copilot finished work on behalf of SoulPancake October 16, 2025 10:00
@SoulPancake SoulPancake changed the title Add comprehensive test coverage for write_options.py and related write request models feat: gen extensive test coverage Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants