Skip to content

Commit

Permalink
Update test_base_claude_ai.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jahwag committed Aug 1, 2024
1 parent 13304ff commit 1cafd50
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@ __pycache__
claude.sync
config.json
claudesync.log
chats
chats
some_value
29 changes: 26 additions & 3 deletions tests/providers/test_base_claude_ai.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest
from unittest.mock import patch

from claudesync.exceptions import ProviderError
from claudesync.providers.base_claude_ai import BaseClaudeAIProvider


Expand All @@ -18,13 +20,34 @@ def test_login(self, mock_prompt):
@patch.object(BaseClaudeAIProvider, "_make_request")
def test_get_organizations(self, mock_make_request):
mock_make_request.return_value = [
{"uuid": "org1", "name": "Org 1"},
{"uuid": "org2", "name": "Org 2"},
{"uuid": "org1", "name": "Org 1", "capabilities": ["chat", "claude_pro"]},
{"uuid": "org2", "name": "Org 2", "capabilities": ["chat"]},
{
"uuid": "org3",
"name": "Org 3",
"capabilities": ["chat", "claude_pro", "other"],
},
{"uuid": "org4", "name": "Org 4", "capabilities": ["other"]},
]
result = self.provider.get_organizations()
expected = [{"id": "org1", "name": "Org 1"}, {"id": "org2", "name": "Org 2"}]
expected = [{"id": "org1", "name": "Org 1"}, {"id": "org3", "name": "Org 3"}]
self.assertEqual(result, expected)

@patch.object(BaseClaudeAIProvider, "_make_request")
def test_get_organizations_no_valid_orgs(self, mock_make_request):
mock_make_request.return_value = [
{"uuid": "org1", "name": "Org 1", "capabilities": ["api"]},
{"uuid": "org2", "name": "Org 2", "capabilities": ["chat"]},
]
result = self.provider.get_organizations()
self.assertEqual(result, [])

@patch.object(BaseClaudeAIProvider, "_make_request")
def test_get_organizations_error(self, mock_make_request):
mock_make_request.return_value = None
with self.assertRaises(ProviderError):
self.provider.get_organizations()

@patch.object(BaseClaudeAIProvider, "_make_request")
def test_get_projects(self, mock_make_request):
mock_make_request.return_value = [
Expand Down

0 comments on commit 1cafd50

Please sign in to comment.