forked from robotframework/PythonLibCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_translations.py
More file actions
71 lines (52 loc) · 2.26 KB
/
Copy pathtest_translations.py
File metadata and controls
71 lines (52 loc) · 2.26 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
from pathlib import Path
import pytest
from SmallLibrary import SmallLibrary
@pytest.fixture(scope="module", params=["path", "dict"])
def lib(request):
translation = Path(__file__).parent.parent / "atest" / "translation.json"
if request.param == "path":
return SmallLibrary(translation=translation)
if request.param == "dict":
json_data = json.loads(translation.read_text(encoding="utf-8"))
return SmallLibrary(translation=json_data)
raise ValueError(request.param)
def test_invalid_translation():
translation = Path(__file__)
assert SmallLibrary(translation=translation)
def test_translations_names(lib: SmallLibrary):
keywords = lib.keywords_spec
assert "other_name" in keywords
assert "name_changed_again" in keywords
def test_translations_docs(lib: SmallLibrary):
keywords = lib.keywords_spec
kw = keywords["other_name"]
assert kw.documentation == "This is new doc"
kw = keywords["name_changed_again"]
assert kw.documentation == "This is also replaced.\n\nnew line."
def test_init_and_lib_docs(lib: SmallLibrary):
keywords = lib.keywords_spec
init = keywords["__init__"]
assert init.documentation == "Replaces init docs with this one."
doc = lib.get_keyword_documentation("__intro__")
assert doc == "New __intro__ documentation is here."
def test_not_translated(lib: SmallLibrary):
keywords = lib.keywords_spec
assert "not_translated" in keywords
doc = lib.get_keyword_documentation("not_translated")
assert doc == "This is not replaced."
def test_doc_not_translated(lib: SmallLibrary):
keywords = lib.keywords_spec
assert "doc_not_translated" not in keywords
assert "this_is_replaced" in keywords
doc = lib.get_keyword_documentation("this_is_replaced")
assert doc == "This is not replaced also."
def test_kw_not_translated_but_doc_is(lib: SmallLibrary):
keywords = lib.keywords_spec
assert "kw_not_translated" in keywords
doc = lib.get_keyword_documentation("kw_not_translated")
assert doc == "Here is new doc"
def test_rf_name_not_in_keywords(lib: SmallLibrary):
kw = lib.keywords
assert "Execute SomeThing" not in kw, f"Execute SomeThing should not be present: {kw}"
assert len(kw) == 6, f"Too many keywords: {kw}"