Spaces:
Sleeping
Sleeping
Download tests/core/test_sharing.py from marqueeH/notebooklm-mcp-cli: direct link, hf CLI and curl.
- Browser
- Download file 3.1 kB
-
https://huggingface.co/spaces/marqueeH/notebooklm-mcp-cli/resolve/main/tests/core/test_sharing.py
- Command line
-
hf download hf://spaces/marqueeH/notebooklm-mcp-cli/tests/core/test_sharing.py
-
curl -L -o test_sharing.py https://huggingface.co/spaces/marqueeH/notebooklm-mcp-cli/resolve/main/tests/core/test_sharing.py
3.1 kB
| """Tests for SharingMixin class.""" | |
| import pytest | |
| from unittest.mock import patch, MagicMock | |
| def test_sharing_mixin_import(): | |
| """Test that SharingMixin can be imported.""" | |
| from notebooklm_tools.core.sharing import SharingMixin | |
| assert SharingMixin is not None | |
| def test_sharing_mixin_inherits_base(): | |
| """Test that SharingMixin inherits from BaseClient.""" | |
| from notebooklm_tools.core.sharing import SharingMixin | |
| from notebooklm_tools.core.base import BaseClient | |
| assert issubclass(SharingMixin, BaseClient) | |
| def test_sharing_mixin_has_methods(): | |
| """Test that SharingMixin has all expected methods.""" | |
| from notebooklm_tools.core.sharing import SharingMixin | |
| expected_methods = [ | |
| 'get_share_status', | |
| 'set_public_access', | |
| 'add_collaborator', | |
| ] | |
| for method_name in expected_methods: | |
| assert hasattr(SharingMixin, method_name), f"Missing method: {method_name}" | |
| def test_get_share_status_uses_correct_rpc(): | |
| """Test that get_share_status calls the correct RPC.""" | |
| from notebooklm_tools.core.sharing import SharingMixin | |
| with patch.object(SharingMixin, '_refresh_auth_tokens'): | |
| with patch.object(SharingMixin, '_call_rpc') as mock_rpc: | |
| mock_rpc.return_value = [] | |
| mixin = SharingMixin(cookies={"test": "cookie"}, csrf_token="test") | |
| mixin.get_share_status("notebook_id_123") | |
| mock_rpc.assert_called_once() | |
| call_args = mock_rpc.call_args | |
| assert call_args[0][0] == "JFMDGd" # RPC_GET_SHARE_STATUS | |
| def test_set_public_access_uses_correct_rpc(): | |
| """Test that set_public_access calls the correct RPC.""" | |
| from notebooklm_tools.core.sharing import SharingMixin | |
| with patch.object(SharingMixin, '_refresh_auth_tokens'): | |
| with patch.object(SharingMixin, '_call_rpc') as mock_rpc: | |
| mock_rpc.return_value = {} | |
| mixin = SharingMixin(cookies={"test": "cookie"}, csrf_token="test") | |
| result = mixin.set_public_access("notebook_id_123", is_public=True) | |
| mock_rpc.assert_called_once() | |
| call_args = mock_rpc.call_args | |
| assert call_args[0][0] == "QDyure" # RPC_SHARE_NOTEBOOK | |
| assert result == "https://notebooklm.google.com/notebook/notebook_id_123" | |
| def test_add_collaborator_uses_correct_rpc(): | |
| """Test that add_collaborator calls the correct RPC.""" | |
| from notebooklm_tools.core.sharing import SharingMixin | |
| with patch.object(SharingMixin, '_refresh_auth_tokens'): | |
| with patch.object(SharingMixin, '_call_rpc') as mock_rpc: | |
| mock_rpc.return_value = {} | |
| mixin = SharingMixin(cookies={"test": "cookie"}, csrf_token="test") | |
| result = mixin.add_collaborator("notebook_id_123", "test@example.com", role="editor") | |
| mock_rpc.assert_called_once() | |
| call_args = mock_rpc.call_args | |
| assert call_args[0][0] == "QDyure" # RPC_SHARE_NOTEBOOK | |
| assert result is True | |