function test_complete_replica_build
Tests the complete local replica build process for a reMarkable device by creating a local copy of all content including folders, documents, notebooks, and PDFs with comprehensive statistics and logging.
/tf/active/vicechatdev/e-ink-llm/cloudtest/test_complete_suite.py
82 - 133
moderate
Purpose
This function serves as a test harness for validating the complete replica building functionality of a reMarkable device synchronization system. It creates a local replica directory, builds a complete copy of all reMarkable content, tracks performance metrics, displays detailed statistics about the sync operation, and shows the resulting directory structure. It's designed for testing, debugging, and demonstrating the replica building capabilities.
Source Code
def test_complete_replica_build(session):
"""Test complete local replica build"""
print("\n" + "=" * 70)
print("šļø TESTING COMPLETE LOCAL REPLICA BUILD")
print("=" * 70)
try:
# Create replica builder
replica_dir = Path.cwd() / "remarkable_complete_replica"
replica = RemarkableLocalReplica(session, str(replica_dir))
print(f"š Replica directory: {replica_dir}")
print(f"š Starting complete replica build...")
print(f" This may take several minutes depending on content size...")
start_time = time.time()
# Build complete replica
success = replica.build_complete_replica()
end_time = time.time()
duration = end_time - start_time
if success:
print(f"\nš COMPLETE REPLICA BUILD SUCCESSFUL!")
print(f" ā±ļø Build duration: {duration:.1f} seconds")
print(f" š Statistics:")
print(f" š Total nodes: {replica.stats['total_nodes']}")
print(f" š Folders: {replica.stats['folders']}")
print(f" š Documents: {replica.stats['documents']}")
print(f" š Notebooks: {replica.stats['notebooks']}")
print(f" š PDFs extracted: {replica.stats['pdfs_extracted']}")
print(f" š Notebooks extracted: {replica.stats['notebooks_extracted']}")
print(f" š Total files extracted: {replica.stats['total_files']}")
print(f" š Replica location: {replica_dir}")
print(f" š¾ Database: {replica.database_file}")
print(f" š Sync log: {replica.sync_log_file}")
# Show directory structure
print(f"\nš REPLICA DIRECTORY STRUCTURE:")
show_directory_tree(replica_dir, max_depth=3)
return True
else:
print("ā Complete replica build failed")
return False
except Exception as e:
print(f"ā Complete replica build error: {e}")
import traceback
traceback.print_exc()
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 interact with the reMarkable cloud API. This session must be valid and authenticated before calling this function.
Return Value
Returns a boolean value: True if the complete replica build was successful (all content downloaded and organized properly), False if the build failed or encountered errors. The function also prints extensive console output with progress updates, statistics, and error messages.
Dependencies
pathlibtimetracebacksys
Required Imports
from pathlib import Path
import time
from auth import RemarkableAuth
from discovery import RemarkableDiscovery
from local_replica import RemarkableLocalReplica
import traceback
Conditional/Optional Imports
These imports are only needed under specific conditions:
import traceback
Condition: only when an exception occurs during replica build to print detailed stack trace
Required (conditional)Usage Example
from auth import RemarkableAuth
from pathlib import Path
import time
from local_replica import RemarkableLocalReplica
import traceback
# First authenticate with reMarkable
auth = RemarkableAuth()
session = auth.authenticate()
# Run the complete replica build test
if session:
success = test_complete_replica_build(session)
if success:
print('Replica build completed successfully')
# Access the replica at: ./remarkable_complete_replica/
else:
print('Replica build failed')
else:
print('Authentication failed')
Best Practices
- Ensure the session object is properly authenticated before calling this function
- Be aware that this function may take several minutes to complete depending on the amount of content
- Ensure sufficient disk space is available before running, as it downloads all reMarkable content
- The function creates a directory named 'remarkable_complete_replica' in the current working directory - ensure this doesn't conflict with existing directories
- Monitor console output for progress updates and error messages during execution
- The function includes comprehensive error handling with traceback printing for debugging
- Review the statistics output to verify all expected content was synchronized
- Check the generated sync log file for detailed operation history
- The function is designed for testing purposes and includes verbose console output that may not be suitable for production use
- Consider implementing cleanup of the replica directory between test runs to avoid conflicts
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function run_complete_test_suite 78.1% similar
-
function main_v15 73.7% similar
-
class RemarkableReplicaSync 73.7% similar
-
class RemarkableLocalReplica 71.9% similar
-
function main_v100 71.1% similar