From 1cafd500b212bd0ef9097ee7d5ae94da398567c2 Mon Sep 17 00:00:00 2001 From: Jahziah Wagner Date: Fri, 2 Aug 2024 00:26:31 +0200 Subject: [PATCH] Update test_base_claude_ai.py --- .gitignore | 3 ++- tests/providers/test_base_claude_ai.py | 29 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 7d8bcf8..8a99f51 100644 --- a/.gitignore +++ b/.gitignore @@ -169,4 +169,5 @@ __pycache__ claude.sync config.json claudesync.log -chats \ No newline at end of file +chats +some_value \ No newline at end of file diff --git a/tests/providers/test_base_claude_ai.py b/tests/providers/test_base_claude_ai.py index 8457fc7..7d7412e 100644 --- a/tests/providers/test_base_claude_ai.py +++ b/tests/providers/test_base_claude_ai.py @@ -1,5 +1,7 @@ import unittest from unittest.mock import patch + +from claudesync.exceptions import ProviderError from claudesync.providers.base_claude_ai import BaseClaudeAIProvider @@ -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 = [