mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-13 08:51:38 +08:00
When enabling the `warn_unused_ignores = True` option of mypy, this
was making the `test_galaxy_packages` tests fail with:
```
mypy .
Traceback (most recent call last):
File "/tmp/gxpkgtestenvu3fgDr/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/tmp/gxpkgtestenvu3fgDr/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "mypy/main.py", line 100, in main
File "mypy/main.py", line 182, in run_build
File "mypy/build.py", line 192, in build
File "mypy/build.py", line 266, in _build
File "mypy/build.py", line 2942, in dispatch
File "mypy/build.py", line 3333, in process_graph
File "mypy/build.py", line 3414, in process_fresh_modules
File "mypy/build.py", line 2110, in fix_cross_refs
File "mypy/fixup.py", line 52, in fixup_module
File "mypy/fixup.py", line 127, in visit_symbol_table
File "mypy/lookup.py", line 49, in lookup_fully_qualified
AssertionError: Cannot find component 'util' for 'galaxy.util'
make: *** [Makefile:96: mypy] Error 1
```
Moreover, installing packages in editable mode was hiding some issues
with how files from other packages were accessed.
77 lines
2.1 KiB
Python
77 lines
2.1 KiB
Python
from pathlib import Path
|
|
|
|
from galaxy.config.schema import AppSchema
|
|
from galaxy.util.yaml_util import (
|
|
ordered_load,
|
|
OrderedLoader,
|
|
)
|
|
|
|
MOCK_YAML = """
|
|
type: map
|
|
desc: mocked schema
|
|
foo: bar
|
|
mapping:
|
|
mockgalaxy:
|
|
type: map
|
|
mapping:
|
|
property1:
|
|
default: a
|
|
type: str
|
|
path_resolves_to: foo
|
|
property2:
|
|
default: 1
|
|
type: int
|
|
reloadable: true
|
|
property3:
|
|
default: 1.0
|
|
type: float
|
|
reloadable: true
|
|
property4:
|
|
default: true
|
|
type: bool
|
|
path_resolves_to: foo
|
|
property5:
|
|
something_else: b
|
|
type: invalid
|
|
property6:
|
|
something_else: b
|
|
"""
|
|
|
|
|
|
def test_schema_is_loaded(monkeypatch):
|
|
def mock_read_schema(self, path):
|
|
return ordered_load(MOCK_YAML)
|
|
|
|
def mock_init(self, stream):
|
|
super(OrderedLoader, self).__init__(stream)
|
|
|
|
monkeypatch.setattr(AppSchema, "_read_schema", mock_read_schema)
|
|
monkeypatch.setattr(OrderedLoader, "__init__", mock_init)
|
|
|
|
schema = AppSchema(Path("no path"), "mockgalaxy")
|
|
data = ordered_load(MOCK_YAML)
|
|
|
|
assert schema.description == data["desc"]
|
|
assert schema.raw_schema["foo"] == "bar"
|
|
|
|
assert len(schema.defaults) == 6
|
|
assert schema.defaults["property1"] == "a"
|
|
assert schema.defaults["property2"] == 1
|
|
assert schema.defaults["property3"] == 1.0
|
|
assert schema.defaults["property4"] is True
|
|
assert schema.defaults["property5"] is None
|
|
assert schema.defaults["property6"] is None
|
|
|
|
assert isinstance(schema.defaults["property1"], str)
|
|
assert isinstance(schema.defaults["property2"], int)
|
|
assert isinstance(schema.defaults["property3"], float)
|
|
assert isinstance(schema.defaults["property4"], bool)
|
|
|
|
assert len(schema.reloadable_options) == 2
|
|
assert "property2" in schema.reloadable_options
|
|
assert "property3" in schema.reloadable_options
|
|
|
|
assert len(schema.paths_to_resolve) == 2
|
|
assert "property1" in schema.paths_to_resolve
|
|
assert "property4" in schema.paths_to_resolve
|