Use wonderwords for shell names

This commit is contained in:
lda
2026-08-30 01:53:53 +07:00 Verified
parent d4d05d12cf
commit cf0ec7b403
4 changed files with 38 additions and 4 deletions
+20
View File
@@ -1,15 +1,35 @@
import contextlib
import importlib
import io
import json
import re
import subprocess
import sys
import unittest
from unittest.mock import Mock, patch
from ipython_demo.app import App
from ipython_demo.models import CallResponse
class AppTests(unittest.TestCase):
def test_generate_good_names_uses_readable_random_words(self):
app_module = importlib.import_module("ipython_demo.app")
generator = Mock()
generator.word.side_effect = ["luminous", "otter"]
with patch.object(
app_module,
"_WORD_GENERATOR",
generator,
create=True,
):
name = app_module.generate_good_names()
self.assertRegex(name, re.compile(r"^[a-z]+-[a-z]+-[0-9a-f]{4}$"))
generator.word.assert_any_call(include_parts_of_speech=["adjectives"])
generator.word.assert_any_call(include_parts_of_speech=["nouns"])
def test_main_emits_one_json_payload(self):
completed = subprocess.run(
[sys.executable, "-c", "from ipython_demo.app import main; main()"],