function test_basic_discovery
Tests the basic hierarchical discovery functionality of a Remarkable device by creating a discovery instance, running discovery, and reporting statistics about discovered nodes.
/tf/active/vicechatdev/e-ink-llm/cloudtest/test_complete_suite.py
50 - 79
moderate
Purpose
This function serves as a test harness for validating the RemarkableDiscovery class's ability to discover and catalog the hierarchical structure of documents and folders on a Remarkable device. It creates an output directory, initiates discovery, and reports success/failure along with statistics including total nodes, folders, documents, and bytes downloaded. The function is designed for testing and validation purposes during development or troubleshooting.
Source Code
def test_basic_discovery(session):
"""Test basic hierarchical discovery"""
print("\n" + "=" * 70)
print("š TESTING BASIC HIERARCHICAL DISCOVERY")
print("=" * 70)
try:
# Create discovery instance with test output directory
output_dir = Path.cwd() / "remarkable_basic_test"
discovery = RemarkableDiscovery(session, str(output_dir))
print(f"š Output directory: {output_dir}")
# Run basic discovery
success = discovery.discover_all()
if success:
print(f"\nā
Basic discovery successful!")
print(f" Nodes discovered: {discovery.stats['total_nodes']}")
print(f" Folders: {discovery.stats['folders']}")
print(f" Documents: {discovery.stats['documents']}")
print(f" Data downloaded: {discovery.stats['bytes_downloaded']:,} bytes")
return True
else:
print("ā Basic discovery failed")
return False
except Exception as e:
print(f"ā Basic discovery error: {e}")
return False
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
session |
- | - | positional_or_keyword |
Parameter Details
session: An authenticated session object (likely from RemarkableAuth) that provides the necessary credentials and connection to communicate with the Remarkable device API. This session must be active and properly authenticated before being passed to this function.
Return Value
Returns a boolean value: True if the discovery process completed successfully and statistics were gathered, False if the discovery failed or an exception occurred during execution. The function also prints detailed status messages and statistics to stdout as side effects.
Dependencies
pathlibtimesystraceback
Required Imports
from pathlib import Path
from auth import RemarkableAuth
from discovery import RemarkableDiscovery
import sys
import time
import traceback
Usage Example
from pathlib import Path
import sys
from auth import RemarkableAuth
from discovery import RemarkableDiscovery
# First authenticate with Remarkable device
auth = RemarkableAuth()
session = auth.authenticate() # Returns authenticated session
# Run the basic discovery test
if session:
result = test_basic_discovery(session)
if result:
print("Discovery test passed")
else:
print("Discovery test failed")
else:
print("Authentication failed")
Best Practices
- Ensure the session parameter is properly authenticated before calling this function
- The function creates a directory 'remarkable_basic_test' in the current working directory - ensure write permissions exist
- This function prints output directly to stdout, making it suitable for interactive testing but not for silent automated tests
- The function catches all exceptions broadly - consider more specific exception handling for production use
- Clean up the output directory after testing to avoid accumulating test data
- The function returns boolean for success/failure but also prints detailed information - consider the output destination when using in automated environments
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function test_discovery 93.8% similar
-
function test_remarkable_discovery 70.5% similar
-
function test_root_finding 68.6% similar
-
function main_v81 63.5% similar
-
function run_full_test_suite 62.4% similar