test: preserve archived debug scripts
This commit is contained in:
35
tests/archive/reproduce_event_file_bug.py
Normal file
35
tests/archive/reproduce_event_file_bug.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Set up project root for imports
|
||||||
|
sys.path.append(os.getcwd())
|
||||||
|
|
||||||
|
# 1. Initialize Mock Config Helper BEFORE other imports
|
||||||
|
import tests.mock_config_helper
|
||||||
|
from app.config import settings
|
||||||
|
|
||||||
|
# Now set some REAL values for DB connection so it actually works
|
||||||
|
import os
|
||||||
|
settings.DB_SERVER = "vpn-db.oneskyit.com"
|
||||||
|
settings.DB_USER = "aether_dev"
|
||||||
|
settings.DB_PASS = "$1sky.AE_dev.2023"
|
||||||
|
settings.DB_NAME = "aether_dev"
|
||||||
|
settings.DB_PORT = 3306
|
||||||
|
settings.REDIS = {"server": "127.0.0.1", "port": 6379}
|
||||||
|
settings.FILES_PATH = {"hosted_files_root": "/home/scott/tmp/gemini_trash"} # Dummy
|
||||||
|
|
||||||
|
from app.methods.event_file_methods import load_event_file_obj
|
||||||
|
from app.db_sql import get_id_random
|
||||||
|
|
||||||
|
print("--- Testing get_id_random directly ---")
|
||||||
|
print(f"event ID 1 -> {get_id_random(1, 'event')}")
|
||||||
|
print(f"session ID 543 -> {get_id_random(543, 'event_session')}")
|
||||||
|
print(f"presenter ID 1629 -> {get_id_random(1629, 'event_presenter')}")
|
||||||
|
|
||||||
|
print("\n--- Testing load_event_file_obj for a2pPIT_W28o ---")
|
||||||
|
res = load_event_file_obj('a2pPIT_W28o', model_as_dict=True)
|
||||||
|
if res:
|
||||||
|
import json
|
||||||
|
print(json.dumps(res, indent=4))
|
||||||
|
else:
|
||||||
|
print("Failed to load object.")
|
||||||
91
tests/archive/test_event_file_model_debug.py
Normal file
91
tests/archive/test_event_file_model_debug.py
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from typing import Optional, Union
|
||||||
|
from pydantic import BaseModel, Field, root_validator
|
||||||
|
|
||||||
|
# Mock base_fields
|
||||||
|
base_fields = {
|
||||||
|
'event_file_id_random': {},
|
||||||
|
'hosted_file_id_random': {},
|
||||||
|
'obj_id_random': {},
|
||||||
|
'event_id_random': {},
|
||||||
|
'event_exhibit_id_random': {},
|
||||||
|
'event_location_id_random': {},
|
||||||
|
'event_presentation_id_random': {},
|
||||||
|
'event_presenter_id_random': {},
|
||||||
|
'event_session_id_random': {},
|
||||||
|
'event_track_id_random': {},
|
||||||
|
}
|
||||||
|
|
||||||
|
class Event_File_Base(BaseModel):
|
||||||
|
id: Optional[Union[int, str]] = Field(None, **base_fields['event_file_id_random'])
|
||||||
|
event_file_id: Optional[Union[int, str]] = Field(None, **base_fields['event_file_id_random'])
|
||||||
|
hosted_file_id: Optional[Union[int, str]] = Field(None, **base_fields['hosted_file_id_random'])
|
||||||
|
for_id: Optional[Union[int, str]] = Field(None, **base_fields['obj_id_random'])
|
||||||
|
event_id: Optional[Union[int, str]] = Field(None, **base_fields['event_id_random'])
|
||||||
|
event_exhibit_id: Optional[Union[int, str]] = Field(None, **base_fields['event_exhibit_id_random'])
|
||||||
|
event_location_id: Optional[Union[int, str]] = Field(None, **base_fields['event_location_id_random'])
|
||||||
|
event_presentation_id: Optional[Union[int, str]] = Field(None, **base_fields['event_presentation_id_random'])
|
||||||
|
event_presenter_id: Optional[Union[int, str]] = Field(None, **base_fields['event_presenter_id_random'])
|
||||||
|
event_session_id: Optional[Union[int, str]] = Field(None, **base_fields['event_session_id_random'])
|
||||||
|
event_track_id: Optional[Union[int, str]] = Field(None, **base_fields['event_track_id_random'])
|
||||||
|
|
||||||
|
id_random: Optional[str] = Field(None, alias='event_file_id_random', exclude=True)
|
||||||
|
hosted_file_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
for_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
event_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
event_exhibit_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
event_location_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
event_presentation_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
event_presenter_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
event_session_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
event_track_id_random: Optional[str] = Field(None, exclude=True)
|
||||||
|
|
||||||
|
@root_validator(pre=True)
|
||||||
|
def map_v3_ids(cls, values):
|
||||||
|
rid = values.get('id_random') or values.get('event_file_id_random')
|
||||||
|
if rid and isinstance(rid, str):
|
||||||
|
values['id'] = rid
|
||||||
|
values['event_file_id'] = rid
|
||||||
|
|
||||||
|
if h_rid := values.get('hosted_file_id_random'): values['hosted_file_id'] = h_rid
|
||||||
|
if f_rid := values.get('for_id_random'): values['for_id'] = f_rid
|
||||||
|
if e_rid := values.get('event_id_random'): values['event_id'] = e_rid
|
||||||
|
if ex_rid := values.get('event_exhibit_id_random'): values['event_exhibit_id'] = ex_rid
|
||||||
|
if loc_rid := values.get('event_location_id_random'): values['event_location_id'] = loc_rid
|
||||||
|
if pres_rid := values.get('event_presentation_id_random'): values['event_presentation_id'] = pres_rid
|
||||||
|
if pr_rid := values.get('event_presenter_id_random'): values['event_presenter_id'] = pr_rid
|
||||||
|
if s_rid := values.get('event_session_id_random'): values['event_session_id'] = s_rid
|
||||||
|
if t_rid := values.get('event_track_id_random'): values['event_track_id'] = t_rid
|
||||||
|
|
||||||
|
id_fields = [
|
||||||
|
'id', 'event_file_id', 'hosted_file_id', 'for_id', 'event_id',
|
||||||
|
'event_exhibit_id', 'event_location_id', 'event_presentation_id',
|
||||||
|
'event_presenter_id', 'event_session_id', 'event_track_id'
|
||||||
|
]
|
||||||
|
for k in id_fields:
|
||||||
|
val = values.get(k)
|
||||||
|
if val is not None and not isinstance(val, str):
|
||||||
|
values[k] = None
|
||||||
|
|
||||||
|
return values
|
||||||
|
|
||||||
|
# Data from DB
|
||||||
|
raw_data = {
|
||||||
|
"id": "2982",
|
||||||
|
"id_random": "a2pPIT_W28o",
|
||||||
|
"hosted_file_id": "2726",
|
||||||
|
"for_type": "event_presenter",
|
||||||
|
"for_id": "1629",
|
||||||
|
"event_id": "1",
|
||||||
|
"event_session_id": "543",
|
||||||
|
"event_presentation_id": "1118",
|
||||||
|
"event_presenter_id": "1629",
|
||||||
|
"event_file_id_random": "a2pPIT_W28o",
|
||||||
|
"hosted_file_id_random": "lFmI035vUqqzqEomJw-sLA",
|
||||||
|
"for_id_random": "uSEvog3bHJo" # Populated by methods.py
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Input Data:", raw_data)
|
||||||
|
obj = Event_File_Base(**raw_data)
|
||||||
|
print("\nOutput Data (dict):", obj.dict())
|
||||||
Reference in New Issue
Block a user