diff options
Diffstat (limited to 'packages/meshbay-hub/tests')
| -rw-r--r-- | packages/meshbay-hub/tests/test_node_page_connection_processes.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_node_page_connection_processes.py b/packages/meshbay-hub/tests/test_node_page_connection_processes.py new file mode 100644 index 0000000..0342e6c --- /dev/null +++ b/packages/meshbay-hub/tests/test_node_page_connection_processes.py @@ -0,0 +1,38 @@ +""" +The Node page offers `connection_processes`, bounded by the machine's cores. + +The node refuses a number above its core count, so a field that let one be +typed would be a field whose Save fails. The ceiling comes with the settings +(`cpu_count`, which the node adds and ignores when it is sent back). +""" + +import re +from pathlib import Path + +STATIC = Path(__file__).resolve().parents[1] / "src" / "meshbay_hub" / "static" + + +def _field() -> str: + src = (STATIC / "node-page.js").read_text(encoding="utf-8") + at = src.index("t('node.setting_connection_processes')") + return src[at:src.index("</label>", at)] + + +def test_the_field_cannot_hold_more_than_the_cores(): + field = _field() + assert "max=${editSettings.cpu_count || 1}" in field + assert re.search(r"Math\.min\(Math\.max\(parseInt\(e\.target\.value\) \|\| 1, 1\), " + r"s\.cpu_count \|\| 1\)", field), ( + "a typed value is not held to the ceiling, only the spinner is") + + +def test_it_says_how_many_cores_there_are(): + assert "t('node.setting_unit_of', { n: editSettings.cpu_count || 1 })" in _field() + + +def test_every_language_names_it(): + for locale in sorted((STATIC / "locales").glob("*.js")): + text = locale.read_text(encoding="utf-8") + assert "'node.setting_connection_processes':" in text, locale.name + m = re.search(r"'node\.setting_unit_of': '([^']*)'", text) + assert m and "{n}" in m.group(1), locale.name |