okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
7f83187
main
1"""Prompts the model schedules for itself must show in the chat sidebar, so 2the user sees what will wake the session without opening /schedule.""" 3 4import json 5import unittest 6 7from harness import Albedo ,Provider ,python ,text 8 9SCHEDULE = ( 10"await commands.schedule('add', 'in:5400 rebuild the index')\n" 11"await commands.schedule('heartbeat', 'every:600 check the ci')" 12) 13 14 15def reply (request ): 16if request ["messages" ][- 1 ].get ("role" )== "user" : 17return python (SCHEDULE ) 18return text ("scheduled" ) 19 20 21class ScheduleTests (unittest .TestCase ): 22def test_model_schedules_show_in_the_sidebar (self ): 23provider = Provider (reply ) 24self .addCleanup (provider .close ) 25with Albedo (provider )as app : 26session = app .session () 27app .prompt (session ,"remind yourself" ).close () 28app .idle (session ) 29with app .api (f"/sessions/ { session } ?tail=0" )as response : 30glances = json .load (response )["glances" ] 31glance = next (g for g in glances if g ["extension" ]== "schedule" ) 32self .assertEqual (glance ["title" ],"scheduled" ) 33self .assertEqual ( 34glance ["url" ],f"/extensions/schedule/jobs?session_id= { session } " 35 ) 36# soonest first, each led by when it fires 37self .assertEqual ( 38 [(row ["badge" ],row ["text" ])for row in glance ["rows" ]], 39 [ 40 ("heartbeat" ,"heartbeat 10m · check the ci" ), 41 ("once" ,"in 1h · rebuild the index" ), 42 ], 43 ) 44 45 46if __name__ == "__main__" : 47unittest .main ()