Files
LangBot/sdk/tests/utils/test_importutil.py
0d84c334ba feat(sdk): move the plugin SDK into the monorepo with independent releases (LANG-420) (#2993)
* chore(sdk): import langbot-plugin-sdk v0.7.24 snapshot into sdk/ (LANG-420)

Snapshot of langbot-app/langbot-plugin-sdk at 76443bb8 (tag v0.7.24),
without history. The repository's .github/ workflows are not imported;
they are replaced by sdk-*.yml workflows in the next commit. The root
.gitignore keeps the template .vscode/launch.json.example tracked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

* feat(sdk): move the plugin SDK into the monorepo with independent releases (LANG-420)

- CI: sdk-tests.yml / sdk-box-docker.yml run the SDK suite from sdk/ in
  its own environment (Python 3.10-3.12); run-tests.yml gains a
  "Core with in-tree SDK" job that overlays sdk/ on Core's venv.
- Releases: sdk-publish.yml publishes langbot-plugin from sdk/vX.Y.Z tag
  pushes and never creates a GitHub Release. Core release workflows now
  only accept v* tags, and scripts/check_sdk_release_pin.py blocks a Core
  PyPI/Docker release whose langbot-plugin pin differs from the released,
  unchanged sdk/.
- Packaging: Core still installs the PyPI pin. Core wheel/sdist, git
  export, Docker context, release ZIP and fnOS package exclude sdk/.
- Generator/tests: generate_plugin_workspace_api.py writes sdk/ directly;
  the SDK's generator drift tests now run instead of skipping.
- Docs: AGENTS/ARCHITECTURE, sdk/ guides (+ RELEASING.md, SOURCE.json),
  agent skills and lbs probes, public docs (zh/en/ja) and dev-docs
  point at sdk/ instead of the sibling langbot-plugin-sdk checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-11-11 23:12:53 +08:00

57 lines
1.7 KiB
Python

from __future__ import annotations
import importlib
import sys
import textwrap
from langbot_plugin.utils import importutil
def test_import_dot_style_dir_imports_python_modules_from_package(
tmp_path, monkeypatch
):
package = tmp_path / "samplepkg"
package.mkdir()
(package / "__init__.py").write_text("", encoding="utf-8")
(package / "alpha.py").write_text("VALUE = 42\n", encoding="utf-8")
(package / "notes.txt").write_text("ignored", encoding="utf-8")
monkeypatch.chdir(tmp_path)
monkeypatch.syspath_prepend(str(tmp_path))
importutil.import_dot_style_dir("samplepkg")
assert importlib.import_module("samplepkg.alpha").VALUE == 42
def test_import_modules_in_pkg_uses_package_file_location(tmp_path, monkeypatch):
package = tmp_path / "anotherpkg"
package.mkdir()
(package / "__init__.py").write_text("", encoding="utf-8")
(package / "beta.py").write_text("FLAG = 'loaded'\n", encoding="utf-8")
monkeypatch.syspath_prepend(str(tmp_path))
pkg = importlib.import_module("anotherpkg")
importutil.import_modules_in_pkg(pkg)
assert sys.modules["anotherpkg.beta"].FLAG == "loaded"
def test_import_dir_skips_init_files(tmp_path, monkeypatch):
package = tmp_path / "thirdpkg"
package.mkdir()
(package / "__init__.py").write_text("RAISED = False\n", encoding="utf-8")
(package / "gamma.py").write_text(
textwrap.dedent(
"""
RESULT = "ok"
"""
),
encoding="utf-8",
)
monkeypatch.chdir(tmp_path)
monkeypatch.syspath_prepend(str(tmp_path))
importutil.import_dir(str(package))
assert importlib.import_module("thirdpkg.gamma").RESULT == "ok"