File: test_compile.py

package info (click to toggle)
python-npe2 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 828 kB
  • sloc: python: 7,088; makefile: 19
file content (31 lines) | stat: -rw-r--r-- 1,142 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pathlib import Path

import pytest

from npe2._inspection import compile
from npe2.manifest.schema import PluginManifest


def test_compile(compiled_plugin_dir: Path, tmp_path: Path):
    """
    Test that the plugin manager can be compiled.
    """
    with pytest.raises(ValueError, match="must have an extension of .json, .yaml, or"):
        compile(compiled_plugin_dir, "bad_path")

    dest = tmp_path / "output.yaml"
    mf = compile(compiled_plugin_dir, dest=dest, packages=["my_module"])
    assert isinstance(mf, PluginManifest)
    assert mf.name == "my_compiled_plugin"
    assert mf.contributions.commands and len(mf.contributions.commands) == 5
    assert dest.exists()
    assert PluginManifest.from_file(dest) == mf


def test_compile_with_template(compiled_plugin_dir: Path, tmp_path: Path):
    """Test building from a template with npe2 compile."""
    template = tmp_path / "template.yaml"
    template.write_text("name: my_compiled_plugin\ndisplay_name: Display Name\n")
    mf = compile(compiled_plugin_dir, template=template)
    assert mf.name == "my_compiled_plugin"
    assert mf.display_name == "Display Name"