blob: 0342e6c9723833bd6700c72107f2adacf88f00b4 (
plain) (
blame)
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
32
33
34
35
36
37
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
|