-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_mc.py
36 lines (26 loc) · 980 Bytes
/
test_mc.py
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
"""
This test shouldn't be run directly with pytest
(unless you really get what's going on)
It is meant to be run by invoking client.marian/test.sh
that shell script spins up a websocket echo server with artificial latency
which this script talks to
"""
import pytest
from essential_generators import DocumentGenerator
from marian_client import MarianClient as MC
TESTS_TO_RUN = 20
gen = DocumentGenerator()
sentences = [gen.sentence() for _ in range(TESTS_TO_RUN)]
try:
# intentionally cause timeouts and retries
mc = MC(PORT=8080, timeout=1, retries=5)
except Exception as e:
raise Exception(
"you need a specifc WS running on localhost:8080 to run theses tests "
"- you also need node.js, a version that supports await syntax"
)
@pytest.mark.parametrize("sent", sentences)
def test_echo_consistency(sent):
global mc
succ, echoed, _ = mc(sent)
assert sent == echoed, "Messages sent to echo server should come back the same"