File size: 1,032 Bytes
8d55ddb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import time

from testcases import ModernMTTestCase, TEST_RESOURCES

TRAIN_FOLDER = os.path.join(TEST_RESOURCES, 'training', 'data')


class HealthCheckTest(ModernMTTestCase):
    mmt_engine_archive = os.path.join(TEST_RESOURCES, 'stub_en_it_engine.tar.gz')

    def test_health_check(self):
        self.mmt.api.health_check()

        result = self.mmt.api.translate('en', 'it', 'hello world')
        self.assertIn('translation', result)
        self.assertGreater(len(result['translation']), 0)

        self.mmt.api.health_check()
        time.sleep(6)
        self.mmt.api.health_check()


class TrainingTest(ModernMTTestCase):
    def test_train_example(self):
        self.mmt.create()
        self.mmt.start()

        self.mmt.api.health_check()

        result = self.mmt.api.translate('en', 'it', 'hello world')
        self.assertIn('translation', result)
        self.assertGreater(len(result['translation']), 0)

        self.mmt.api.health_check()
        time.sleep(6)
        self.mmt.api.health_check()