forked from felixonmars/fcitx5-pinyin-zhwiki
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
218 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from mw2fcitx.tweaks.moegirl import tweaks | ||
|
||
exports = { | ||
"source": { | ||
"kwargs": { | ||
"title_limit": 50, | ||
"output": "test_result.txt" | ||
} | ||
}, | ||
"tweaks": | ||
tweaks, | ||
"converter": { | ||
"use": "opencc", | ||
"kwargs": {} | ||
}, | ||
"generator": [{ | ||
"use": "rime", | ||
"kwargs": { | ||
"name": "err_local", | ||
"output": "err_local.dict.yml" | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from mw2fcitx.tweaks.moegirl import tweaks | ||
|
||
exports = { | ||
"source": { | ||
"file_path": "tests/cli/test.txt", | ||
"kwargs": { | ||
"title_limit": 50, | ||
"output": "test_result.txt" | ||
} | ||
}, | ||
"tweaks": | ||
tweaks, | ||
"converter": { | ||
"use": "opencc", | ||
"kwargs": {} | ||
}, | ||
"generator": [{ | ||
"use": "rime", | ||
"kwargs": { | ||
"name": "e2etest_local", | ||
"output": "test_local_result.dict.yml" | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from mw2fcitx.tweaks.moegirl import tweaks | ||
|
||
exports = { | ||
"source": { | ||
"api_path": "https://zh.wikipedia.org/w/api.php", | ||
"kwargs": { | ||
"title_limit": 50, | ||
"output": "titles.txt" | ||
} | ||
}, | ||
"tweaks": | ||
tweaks, | ||
"converter": { | ||
"use": "opencc", | ||
"kwargs": {} | ||
}, | ||
"generator": { | ||
"use": "rime", | ||
"kwargs": { | ||
"output": "moegirl.dict.yml" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
初音未来 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from mw2fcitx.main import inner_main | ||
import pytest | ||
|
||
|
||
def test_inner_main_name_without_py(): | ||
inner_main(['-c', 'tests/cli/conf_one']) | ||
|
||
|
||
def test_inner_main_name_with_py(): | ||
inner_main(['-c', 'tests/cli/conf_one.py']) | ||
|
||
|
||
def test_single_generator(): | ||
inner_main(['-c', 'tests/cli/conf_single_generator']) | ||
|
||
|
||
def test_local(): | ||
inner_main(['-c', 'tests/cli/conf_local']) | ||
with open("test_local_result.dict.yml", "r") as f: | ||
assert (f.read() == """--- | ||
name: e2etest_local | ||
version: "0.1" | ||
sort: by_weight | ||
... | ||
初音未来 chu yin wei lai | ||
""") | ||
|
||
|
||
def test_err_no_path(): | ||
with pytest.raises(SystemExit): | ||
inner_main(['-c', 'tests/cli/conf_err_no_path']) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
from mw2fcitx.utils import is_libime_used, sanitize, smart_rewrite | ||
|
||
|
||
def test_is_libime_used(): | ||
assert ( | ||
is_libime_used({}) == False | ||
) | ||
|
||
assert ( | ||
is_libime_used({ | ||
"generator": [{ | ||
"use": "rime", | ||
"kwargs": { | ||
"output": "1.yml" | ||
} | ||
}] | ||
}) == False | ||
) | ||
|
||
assert ( | ||
is_libime_used({ | ||
"generator": [{ | ||
"use": "rime", | ||
"kwargs": { | ||
"output": "1.yml" | ||
} | ||
}, { | ||
"use": "pinyin", | ||
"kwargs": { | ||
"output": "1.dict" | ||
} | ||
}] | ||
}) == True | ||
) | ||
|
||
|
||
def test_sanitize(): | ||
def test(): | ||
pass | ||
assert ( | ||
sanitize(test) == "[func test]" | ||
) | ||
|
||
assert (sanitize(lambda x: x) == "[func <lambda>]") | ||
|
||
assert (sanitize({ | ||
"a": [1, "b"], | ||
"c": { | ||
"d": None | ||
} | ||
}) == { | ||
"a": ['1', "b"], | ||
"c": { | ||
"d": "[<class 'NoneType'>]" | ||
} | ||
}) | ||
|
||
|
||
def test_smart_rewrite(): | ||
assert ( | ||
smart_rewrite( | ||
{ | ||
"generator": [], | ||
"source": { | ||
"file_path": [] | ||
} | ||
} | ||
) == { | ||
"generator": [], | ||
"source": { | ||
"file_path": [] | ||
} | ||
} | ||
) | ||
|
||
assert ( | ||
smart_rewrite( | ||
{ | ||
"generator": { | ||
"use": "rime", | ||
"kwargs": { | ||
"output": "moegirl.dict.yml" | ||
} | ||
}, | ||
"source": { | ||
"file_path": [] | ||
} | ||
} | ||
) == { | ||
"generator": [{ | ||
"use": "rime", | ||
"kwargs": { | ||
"output": "moegirl.dict.yml" | ||
} | ||
}], | ||
"source": { | ||
"file_path": [] | ||
} | ||
} | ||
) | ||
|
||
assert ( | ||
smart_rewrite( | ||
{ | ||
"generator": [], | ||
"source": { | ||
"file_path": "1.txt" | ||
} | ||
} | ||
) == { | ||
"generator": [], | ||
"source": { | ||
"file_path": ["1.txt"] | ||
} | ||
} | ||
) |