First Commit
This commit is contained in:
Executable
+106
@@ -0,0 +1,106 @@
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, "/home/marco/MonicaAgentIA/app")
|
||||
|
||||
os.environ["TELEGRAM_BOT_TOKEN"] = "test"
|
||||
os.environ["TELEGRAM_CHAT_ID"] = "123"
|
||||
|
||||
from monica_agent import (
|
||||
adicionaracoesauto_command,
|
||||
load_user_profile,
|
||||
save_user_profile,
|
||||
load_all_contexts,
|
||||
add_to_context,
|
||||
)
|
||||
|
||||
class FakeMessage:
|
||||
def __init__(self, text):
|
||||
self.text = text
|
||||
self.chat_id = 7889499475
|
||||
|
||||
async def reply_text(self, text, **kwargs):
|
||||
print(f"BOT RESPONSE: {text[:500]}")
|
||||
|
||||
async def edit_text(self, text, **kwargs):
|
||||
print(f"BOT EDIT: {text[:500]}")
|
||||
|
||||
class FakeUpdate:
|
||||
def __init__(self, text):
|
||||
self.message = FakeMessage(text)
|
||||
self.effective_chat = self
|
||||
self.effective_user = self
|
||||
self.effective_message = self.message
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self.message.chat_id
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return "test_user"
|
||||
|
||||
@property
|
||||
def first_name(self):
|
||||
return "Marco"
|
||||
|
||||
class FakeContext:
|
||||
def __init__(self):
|
||||
self.bot = self
|
||||
|
||||
async def send_message(self, **kwargs):
|
||||
print(f"BOT SEND: {kwargs.get('text', '')[:500]}")
|
||||
|
||||
async def test_adicionaracoesauto_command():
|
||||
print("=== Testando /adicionaraçõesauto ===")
|
||||
|
||||
profile = load_user_profile()
|
||||
profile["name"] = "Marco"
|
||||
profile["interests"] = ["Programar", "Violão"]
|
||||
profile["personality_traits"] = ["extrovertido"]
|
||||
profile["preferences"] = {
|
||||
"communication_style": "direta",
|
||||
"topics_of_interest": ["tecnologia"],
|
||||
"topics_to_avoid": ["política"],
|
||||
}
|
||||
profile["sexual_preferences"] = {
|
||||
"openness": "Sim, confortável",
|
||||
"preferred_topics": ["sedução"],
|
||||
"boundaries": ["Não"],
|
||||
}
|
||||
profile["monica_sexual_preferences"] = [
|
||||
"Gosta de dar palmadas",
|
||||
"Gosta de enfiar dedos",
|
||||
]
|
||||
profile["monica_visual_preferences"] = [
|
||||
"Gosta de ver pelado",
|
||||
]
|
||||
save_user_profile(profile)
|
||||
|
||||
add_to_context("user", "Hoje estou trabalhando em casa, programando um projeto novo em Arduino.")
|
||||
add_to_context("assistant", "Que legal, amor! Adoro ver você programando.")
|
||||
|
||||
update = FakeUpdate("/adicionaraçõesauto")
|
||||
context = FakeContext()
|
||||
|
||||
try:
|
||||
await adicionaracoesauto_command(update, context)
|
||||
print("✅ adicionaracoesauto_command executou sem erros")
|
||||
|
||||
final_profile = load_user_profile()
|
||||
if final_profile.get("interests") != profile.get("interests"):
|
||||
print("✅ Perfil foi atualizado (interesses modificados)")
|
||||
else:
|
||||
print(" Perfil pode não ter sido modificado (nada novo encontrado - também é válido)")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erro: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
async def main():
|
||||
await test_adicionaracoesauto_command()
|
||||
print("\n=== Teste concluído ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user