This repository was archived by the owner on Apr 23, 2025. It is now read-only.
forked from raizamartin/gemini-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Improve config test coverage #6
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7c19961
Add tests for main module to improve coverage
ipv1337 051d577
Add tests for BaseTool class to improve coverage
ipv1337 ff8eb70
Add documentation for test coverage improvements
ipv1337 07c4ad5
Move test coverage documentation to docs directory
ipv1337 64fc2de
Add coverage_report.xml to .gitignore
ipv1337 909590a
Update tests/test_main.py
ipv1337 4d47597
Add GitHub auth wrapper and memory management scripts
ipv1337 cbb9033
Fix config module compatibility issues and improve test coverage
ipv1337 60a53a1
Fix test_get_default_model_edge_cases for compatibility with implemen…
ipv1337 5b724a9
Merge branch 'main' into feature/improve-test-coverage
ipv1337 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
| # ghauth.sh - GitHub CLI wrapper to use the correct authentication token | ||
| # Usage: source scripts/ghauth.sh | ||
| # ghauth <any-gh-command> | ||
|
|
||
| ghauth() { | ||
| GITHUB_TOKEN="" gh "$@" | ||
| } | ||
|
|
||
| echo "GitHub CLI auth wrapper loaded. Use 'ghauth' instead of 'gh' for commands requiring full repo access." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/bin/bash | ||
| # memory.sh - Backup and restore assistant memory | ||
| # Usage: | ||
| # ./scripts/memory.sh backup - Creates a backup of assistant memory | ||
| # ./scripts/memory.sh restore - Provides instructions to restore memory | ||
|
|
||
| BACKUP_FILE="scripts/memory_backup.json" | ||
|
|
||
| function backup_memory() { | ||
| echo "To create a memory backup:" | ||
| echo "1. Ask the assistant: 'Please create a memory backup'" | ||
| echo "2. The assistant will use mcp_memory_read_graph tool to read current memory" | ||
| echo "3. The assistant will update $BACKUP_FILE with current memory contents" | ||
| echo | ||
| echo "You can also ask the assistant to add specific information to memory before backing up." | ||
| } | ||
|
|
||
| function restore_memory() { | ||
| if [ ! -f "$BACKUP_FILE" ]; then | ||
| echo "Backup file not found: $BACKUP_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "This script will help you restore memory in a new assistant session." | ||
| echo "Instructions:" | ||
| echo "1. When starting a new chat with the assistant, paste the following instructions:" | ||
| echo | ||
| echo "------- COPY BELOW THIS LINE -------" | ||
| echo "Please restore my memory backup from the scripts/memory_backup.json file" | ||
| echo "Steps:" | ||
| echo "1. Read the file content with read_file tool" | ||
| echo "2. Parse the JSON content" | ||
| echo "3. Create entities and relations from the backup using memory tools" | ||
| echo "4. Confirm when memory has been restored" | ||
| echo "------- COPY ABOVE THIS LINE -------" | ||
| echo | ||
| echo "The assistant will then be able to restore its memory from the backup file." | ||
| } | ||
|
|
||
| case "$1" in | ||
| backup) | ||
| backup_memory | ||
| ;; | ||
| restore) | ||
| restore_memory | ||
| ;; | ||
| *) | ||
| echo "Usage: $0 {backup|restore}" | ||
| echo " backup - Provides instructions for backing up assistant memory" | ||
| echo " restore - Provides instructions for restoring assistant memory" | ||
| exit 1 | ||
| ;; | ||
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| { | ||
| "entities": [ | ||
| { | ||
| "type": "entity", | ||
| "name": "James", | ||
| "entityType": "Person", | ||
| "observations": [ | ||
| "Is the current user I am interacting with", | ||
| "Has workspace path /Users/james/Workspace/gh/lab/monorepo", | ||
| "Is working on the BlueCentre/monorepo repository", | ||
| "GitHub username is ipv1337" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "entity", | ||
| "name": "SlackConnection", | ||
| "entityType": "Connection", | ||
| "observations": [ | ||
| "Connection ID: a7ea21c2-02f8-4ac1-bca0-ed02014496de", | ||
| "Status: ACTIVE", | ||
| "Created at: 2025-04-03T08:33:29.676Z", | ||
| "Updated at: 2025-04-03T08:33:52.375Z" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "entity", | ||
| "name": "Slack Integration", | ||
| "entityType": "Tool Connection", | ||
| "observations": [ | ||
| "Has active connection with ID: a7ea21c2-02f8-4ac1-bca0-ed02014496de", | ||
| "Can fetch conversation history", | ||
| "Can post messages", | ||
| "Can add reactions", | ||
| "Can create reminders", | ||
| "Can list custom emojis" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "entity", | ||
| "name": "Google Tasks Integration", | ||
| "entityType": "Tool Connection", | ||
| "observations": [ | ||
| "No active connection found", | ||
| "Connection attempt failed with error: Could not find a connection", | ||
| "Requires authentication setup", | ||
| "Connection successfully established with ID: 63629ab1-e9f9-4c8c-b8c3-e34ceec4e028", | ||
| "Access to 6 task lists including: My Tasks, DCX Tasks, OOMS Tasks, HR Tasks, Documentation Tasks, and My Long Term Tasks", | ||
| "Can list, create, update, and delete tasks and task lists", | ||
| "Connection established via OAuth", | ||
| "Last connection update: 2025-04-03T08:42:11.549Z" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "entity", | ||
| "name": "GCP Integration", | ||
| "entityType": "Tool Connection", | ||
| "observations": [ | ||
| "Has active connection", | ||
| "Access to multiple projects (500+ projects listed)", | ||
| "Can perform GCP operations", | ||
| "Can run GCP code", | ||
| "Can manage billing information", | ||
| "Can manage GKE clusters" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "entity", | ||
| "name": "Development Best Practices", | ||
| "entityType": "Workflow", | ||
| "observations": [ | ||
| "Always test and validate changes locally before committing and pushing to the repository", | ||
| "For configuration changes, verify that all supported configurations work as expected", | ||
| "When adding new features like environment variable support, test with real settings" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "entity", | ||
| "name": "GitHub CLI Auth Workaround", | ||
| "entityType": "TechnicalSolution", | ||
| "observations": [ | ||
| "When GitHub CLI operations fail with 'Resource not accessible by personal access token' errors, temporarily unset GITHUB_TOKEN", | ||
| "Command pattern to use: GITHUB_TOKEN=\"\" gh <command>", | ||
| "This bypasses the environment variable token and uses the properly scoped token stored in keyring", | ||
| "For this user, the keyring token has 'admin:public_key', 'codespace', 'gist', 'read:org', 'repo' scopes" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "entity", | ||
| "name": "CLI-Code Development Workflow", | ||
| "entityType": "Workflow", | ||
| "observations": [ | ||
| "Add coverage_report.xml to .gitignore to avoid committing generated test artifacts", | ||
| "Use GitHub CLI with proper authentication by using the ghauth wrapper script", | ||
| "Run tests locally before pushing changes", | ||
| "Create PRs against the main branch", | ||
| "When encountering GitHub authentication issues, use GITHUB_TOKEN=\"\" gh command pattern" | ||
| ] | ||
| } | ||
| ], | ||
| "relations": [ | ||
| { | ||
| "type": "relation", | ||
| "from": "James", | ||
| "to": "SlackConnection", | ||
| "relationType": "has authenticated" | ||
| }, | ||
| { | ||
| "type": "relation", | ||
| "from": "Slack Integration", | ||
| "to": "Tool Connection", | ||
| "relationType": "is connected" | ||
| }, | ||
| { | ||
| "type": "relation", | ||
| "from": "GCP Integration", | ||
| "to": "Tool Connection", | ||
| "relationType": "is connected" | ||
| }, | ||
| { | ||
| "type": "relation", | ||
| "from": "Google Tasks Integration", | ||
| "to": "Tool Connection", | ||
| "relationType": "is connected" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/bin/bash | ||
| # memory_restore.sh - Restore assistant memory from backup | ||
| # Usage: ./scripts/memory_restore.sh | ||
|
|
||
| BACKUP_FILE="scripts/memory_backup.json" | ||
|
|
||
| if [ ! -f "$BACKUP_FILE" ]; then | ||
| echo "Backup file not found: $BACKUP_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "This script will help you restore memory in a new assistant session." | ||
| echo "Instructions:" | ||
| echo "1. When starting a new chat with the assistant, paste the following instructions:" | ||
| echo | ||
| echo "------- COPY BELOW THIS LINE -------" | ||
| echo "Please restore my memory backup from the scripts/memory_backup.json file" | ||
| echo "Steps:" | ||
| echo "1. Read the file content with read_file tool" | ||
| echo "2. Parse the JSON content" | ||
| echo "3. Create entities and relations from the backup using memory tools" | ||
| echo "4. Confirm when memory has been restored" | ||
| echo "------- COPY ABOVE THIS LINE -------" | ||
| echo | ||
| echo "The assistant will then be able to restore its memory from the backup file." | ||
|
|
||
| chmod +x "$0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -286,7 +286,7 @@ def test_get_default_model_edge_cases(self): | |||||||||||||||
| with patch.object(Config, 'get_default_provider', return_value='gemini'): | ||||||||||||||||
| # Test with empty config | ||||||||||||||||
| config.config = {} | ||||||||||||||||
| self.assertEqual(config.get_default_model('gemini'), "models/gemini-2.5-pro-exp-03-25") | ||||||||||||||||
| self.assertEqual(config.get_default_model('gemini'), "models/gemini-1.5-pro-latest") | ||||||||||||||||
|
Comment on lines
288
to
+289
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test uses a hardcoded default model name. It would be better to use a configurable value or dynamically generate the model name to avoid issues when the default model changes.
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| # Test with unknown provider directly (not using get_default_provider) | ||||||||||||||||
| self.assertIsNone(config.get_default_model('unknown')) | ||||||||||||||||
|
|
||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning
Nonehere is inconsistent with other functions likeset_credentialwhich simply return without a value. Consider raising an exception or returning a consistent error value to improve error handling.