Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enhance file module with improved documentation and tests #92

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Jan 30, 2025

File Module Improvements

This PR enhances the file module with improved documentation and test coverage to better align with the official Notecard API documentation.

Changes

  • Enhanced docstrings with detailed return type information
  • Added comprehensive test coverage for file module methods
  • Fixed line length and linting issues
  • Added card fixture to conftest.py for better test organization
  • Improved error handling with specific error messages for missing fields and type validation
  • Added new test file for file.changes.pending functionality

Testing

  • Added test files:
    • test_file_changes.py
    • test_file_delete.py
    • test_file_stats.py
    • test_file_changes_pending.py
  • Enhanced error handling tests for:
    • Missing required fields
    • Invalid field types
    • Malformed responses
    • Edge cases (zero values, unexpected fields)
  • All tests pass across Python versions
  • Flake8 compliant

Documentation

Updated docstrings to accurately reflect:

  • Response structures for all file module methods
  • Optional parameters and their behavior
  • Success/failure conditions
  • Error handling behavior and validation

Link to Devin run: https://app.devin.ai/sessions/95ffd763d71b445198b9370e49dcd93f

devin-ai-integration bot and others added 29 commits January 29, 2025 16:16
- Add type validation for template body fields
- Implement binary record support with length validation
- Add port number validation (1-100)
- Support compact format with metadata field validation
- Update API documentation with new features
- Add comprehensive test suite

Co-Authored-By: [email protected] <[email protected]>
- Add file parameter to file.stats method
- Update docstrings with accurate return type information
- Add comprehensive test coverage for file module methods
- Split tests into separate files for better organization

Co-Authored-By: [email protected] <[email protected]>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

docs/api.md Outdated
* `file` The name of the file.
* `body` A JSON object to add to the note.
* `payload` An optional base64-encoded string.
* `binary` Binary data (bytearray) to be stored in the note.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary is a boolean value, not a byte array. please see these docs: https://dev.blues.io/api-reference/notecard-api/note-requests/latest/#note-add

notecard/file.py Outdated
response = card.Transaction(req)
if "err" in response:
return response
# Check for required fields first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking for "required" fields in the response is not a valid test. this is because notecard uses omitempty by default, meaning if there is a 0, false, or empty string "", that value would be omitted from the response.

notecard/file.py Outdated
response = card.Transaction(req)
if "err" in response:
return response
# Check for required fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking for "required" fields in the response is not a valid test. this is because notecard uses omitempty by default, meaning if there is a 0, false, or empty string "", that value would be omitted from the response.

notecard/file.py Outdated
response = card.Transaction(req)
if "err" in response:
return response
# Validate response format - should contain total and changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking for "required" fields in the response is not a valid test. this is because notecard uses omitempty by default, meaning if there is a 0, false, or empty string "", that value would be omitted from the response.

notecard/note.py Outdated Show resolved Hide resolved
notecard/note.py Outdated
return {"err": "verify parameter must be a boolean"}

if length is not None:
if not isinstance(length, int) or length < 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length can be a negative number (it effectively resets the value to its default)

notecard/note.py Outdated
req["format"] = "compact"
if body:
allowed_metadata = {"_time", "_lat", "_lon", "_loc"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_loc is not a valid value here, it should be replaced with _ltime

}
response = file.changes(card)
# First validate the response has all required fields
assert 'changes' in response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these assert statements are invalid since notecard uses omitempty and those values may not exist on the response

Copy link
Contributor Author

Devin is currently unreachable - the session may have died.

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.

1 participant