Skip to content

Commit 925bf81

Browse files
🐛 Workaround lack of Plover's config file in CI.
1 parent ebca8fb commit 925bf81

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/test_public_key_request.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,37 @@
88
from asyncio import get_event_loop
99
from nacl_middleware import Nacl
1010

11-
SERVER_CONFIG_FILE = "plover_websocket_server_config.json"
11+
from json import dump
12+
from os import makedirs
1213

14+
SERVER_CONFIG_FILE = "plover_websocket_server_config.json"
1315
config_path: str = os.path.join(CONFIG_DIR, SERVER_CONFIG_FILE)
1416

17+
def is_ci_environment():
18+
ci_vars = ['CI', 'TRAVIS', 'GITHUB_ACTIONS', 'CIRCLECI', 'JENKINS_HOME']
19+
return any(var in os.environ for var in ci_vars)
20+
21+
if is_ci_environment():
22+
# Make sure there is a config folder
23+
makedirs(CONFIG_DIR, exist_ok=True)
24+
25+
# random data
26+
data = {
27+
"private_key": "f4a8ac4dcee327231712ded32f6171962b8a430efa20a1c8c2943c6fdf05074e",
28+
"public_key": "a76e938fb83d0d95b8b1f249f9aa1ab47c5159f31a052e1d366d18488573ee30",
29+
"host": "localhost",
30+
"port": 8086,
31+
"remotes": [
32+
{
33+
"pattern": "^https?\\:\\/\\/localhost?(:[0-9]*)?"
34+
}
35+
]
36+
}
37+
38+
with open(config_path, "w", encoding="utf-8") as config_file:
39+
dump(data, config_file, indent=2)
40+
41+
1542
config = ServerConfig(
1643
config_path
1744
) # reload the configuration when the server is restarted

0 commit comments

Comments
 (0)