* make tests dummy to make sure github workflow is fine * black test * strip circular import * further dummy-fy the test * use pexpect * need y * Update tests.yml * Update tests.yml * added prints * sleep before decode print * updated test to match legacy flow * revising test where it fails * comment out enter your message check for now, pexpect seems to be stuck on only setting the bootup message * weird now it's not showing Bootup sequence complete? * added debug * handle none * allow more time * loosen string check * add enter after commands * modify saved compontent snippet * add try again check * more sendlines * more excepts * test passing locally * Update tests.yml * dont clearline * add EOF catch that seems to only happen on github actiosn (ubuntu) but not macos * more eof * try flushing * add strip_ui flag * fix archival_memory_search and memory print output * Don't use questionary for input if strip_ui * Run black * Always strip UI if TEST is set * Add another flush * expect Enter your message * more debug prints * one more shot at printing debug info * stray fore color in stripped ui * tests pass locally * cleanup --------- Co-authored-by: Vivian Fang <hi@vivi.sh>
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
import pexpect
|
|
|
|
|
|
TIMEOUT = 30 # seconds
|
|
|
|
|
|
def test_legacy_cli_sequence():
|
|
# Start the CLI process
|
|
child = pexpect.spawn("memgpt --first --strip_ui")
|
|
|
|
child.expect("Continue with legacy CLI?", timeout=TIMEOUT)
|
|
# Send 'Y' followed by newline
|
|
child.sendline("Y")
|
|
|
|
# Since .memgpt is empty, should jump immediately to "Which model?"
|
|
child.expect("Which model would you like to use?", timeout=TIMEOUT)
|
|
child.sendline()
|
|
|
|
child.expect("Which persona would you like MemGPT to use?", timeout=TIMEOUT)
|
|
child.sendline()
|
|
|
|
child.expect("Which user would you like to use?", timeout=TIMEOUT)
|
|
child.sendline()
|
|
|
|
child.expect("Would you like to preload anything into MemGPT's archival memory?", timeout=TIMEOUT)
|
|
child.sendline() # Default No
|
|
|
|
child.expect("Testing messaging functionality", timeout=TIMEOUT)
|
|
child.expect("Enter your message", timeout=TIMEOUT)
|
|
child.sendline() # Send empty message
|
|
|
|
child.expect("Try again!", timeout=TIMEOUT) # Empty message
|
|
child.sendline("/save")
|
|
|
|
child.expect("Saved checkpoint", timeout=TIMEOUT)
|
|
child.sendline("/load")
|
|
|
|
child.expect("Loaded persistence manager", timeout=TIMEOUT)
|
|
child.sendline("/exit")
|
|
child.expect("Finished.", timeout=TIMEOUT)
|
|
|
|
child.expect(pexpect.EOF, timeout=TIMEOUT) # Wait for child to exit
|
|
child.close()
|
|
assert child.isalive() is False, "CLI should have terminated."
|
|
assert child.exitstatus == 0, "CLI did not exit cleanly."
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_legacy_cli_sequence()
|