learn progress
This commit is contained in:
41
Html/test_progress.py
Normal file
41
Html/test_progress.py
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add the project root to the Python path
|
||||
sys.path.insert(0, '/Users/cakecai/Documents/gitea/hsa/Html')
|
||||
|
||||
from flask import Flask
|
||||
from flask_pymongo import PyMongo
|
||||
|
||||
# Create a minimal Flask app for testing
|
||||
app = Flask(__name__)
|
||||
app.config['MONGO_URI'] = 'mongodb://localhost:27017/test_db'
|
||||
mongo = PyMongo(app)
|
||||
|
||||
# Register the mongo extension with the app
|
||||
app.extensions = {'mongo': mongo}
|
||||
|
||||
# Import the function to test
|
||||
with app.app_context():
|
||||
from apps.services.course_services.learning_progess_process import load_learning_progress
|
||||
|
||||
# Test with non-existent record
|
||||
print("Testing with non-existent record:")
|
||||
result = load_learning_progress("test_user", "test_course", "test_chapter", "test_lesson")
|
||||
print(f"Result: {result}")
|
||||
print(f"Exists: {result['exists']}")
|
||||
print(f"Data keys: {list(result['data'].keys())}")
|
||||
print(f"Message: {result['message']}")
|
||||
print("\n")
|
||||
|
||||
# Test that default values are correctly set
|
||||
print("Testing default values:")
|
||||
print(f"Chat historys: {result['data']['chat_historys']}")
|
||||
print(f"Scores: {result['data']['scores']}")
|
||||
print(f"Chapter chain now: {result['data']['chapter_chain_now']}")
|
||||
print(f"Updated at: {result['data']['updated_at']}")
|
||||
print("\n")
|
||||
|
||||
print("Test completed successfully!")
|
||||
Reference in New Issue
Block a user