예제 #1
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_metrics(self, m):
     m.get(
         'https://api-demo.lingo24.com/docs/v1/projects/1/jobs/123/metrics',
         text=json.dumps({
             'values': {
                 'AAA': {
                     'WHITE_SPACES': 1,
                     'SEGMENTS': 2,
                     'WORDS': 3,
                     'CHARACTERS': 4
                 },
                 'BBB': {
                     'WHITE_SPACES': 5,
                     'SEGMENTS': 6,
                     'WORDS': 7,
                     'CHARACTERS': 8
                 },
                 'CCC': {
                     'WHITE_SPACES': 9,
                     'SEGMENTS': 10,
                     'WORDS': 11,
                     'CHARACTERS': 12
                 },
             }
         }))
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertDictEqual(
         job.metrics, {
             'AAA': Metric(1, 2, 3, 4),
             'BBB': Metric(5, 6, 7, 8),
             'CCC': Metric(9, 10, 11, 12),
         })
예제 #2
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def setUp(self):
     authenticator = Authenticator('xxx', 'yyy',
                                   'https://www.example.com/callback')
     authenticator.store.set({'access_token': 'aaa'})
     self.client = Client(authenticator, 'demo', per_page=4)
     self.project = Project(self.client, 1, 'aaa', 123, 'bbb',
                            datetime.datetime.utcfromtimestamp(123), 'ccc')
     self.job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
예제 #3
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_service(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/services/2',
           text=json.dumps({
               'id': 2,
               'name': 'aaa',
               'description': 'AAA',
           }))
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertEqual(job.service, Service(2, 'aaa', 'AAA'))
예제 #4
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_source_file(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/files/5',
           text=json.dumps({
               'id': 5,
               'name': 'Source.txt',
               'type': 'SOURCE',
           }))
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertEqual(job.source_file,
                      File(self.client, 5, 'Source.txt', 'SOURCE'))
예제 #5
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_target_file(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/files/6',
           text=json.dumps({
               'id': 6,
               'name': 'Target.txt',
               'type': 'TARGET',
           }))
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertEqual(job.target_file,
                      File(self.client, 6, 'Target.txt', 'TARGET'))
예제 #6
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_target_locale(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/locales/4',
           text=json.dumps({
               'id': 4,
               'name': 'aaa',
               'language': 'AAA',
               'country': 'xxx',
           }))
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertEqual(job.target_locale, Locale(4, 'aaa', 'AAA', 'xxx'))
예제 #7
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_price(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/projects/1/jobs/123/price',
           text=json.dumps({
               'currencyCode': 'GBP',
               'totalWoVatWDiscount': '11.11',
               'totalWVatWDiscount': '22.22',
               'totalWoVatWoDiscount': '33.33',
               'totalWVatWoDiscount': '44.44',
           }))
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertEqual(
         job.price,
         TotalPrice(
             total_with_discount=Price('GBP', Decimal('11.11'),
                                       Decimal('22.22')),
             total_without_discount=Price('GBP', Decimal('33.33'),
                                          Decimal('44.44')),
         ))
예제 #8
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_delete(self, m):
     m.delete('https://api-demo.lingo24.com/docs/v1/projects/1/jobs/123')
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     job.delete()
예제 #9
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_target_file_missing(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/files/6', status_code=404)
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertRaises(DoesNotExist, lambda: job.target_file)
예제 #10
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_client(self):
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertEqual(job.client, self.client)
예제 #11
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_url_path(self):
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertEqual(job.url_path, 'projects/1/jobs/123')
예제 #12
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_target_file_error(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/files/6', status_code=500)
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertRaises(APIError, lambda: job.target_file)
예제 #13
0
파일: jobs.py 프로젝트: RossLote/lingo24
    def test_equality(self):
        project2 = Project(self.client, 1, 'aaa', 2, 'bbb',
                           datetime.datetime.utcfromtimestamp(123), 'ccc')

        self.assertEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                         Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6))
        self.assertNotEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                            Job(self.project.jobs, 10, 'aaa', 2, 3, 4, 5, 6))
        self.assertNotEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                            Job(self.project.jobs, 1, 'bbb', 2, 3, 4, 5, 6))
        self.assertNotEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                            Job(self.project.jobs, 1, 'aaa', 20, 3, 4, 5, 6))
        self.assertNotEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                            Job(self.project.jobs, 1, 'aaa', 2, 30, 4, 5, 6))
        self.assertNotEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                            Job(self.project.jobs, 1, 'aaa', 2, 3, 40, 5, 6))
        self.assertNotEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                            Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 50, 6))
        self.assertNotEqual(Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 6),
                            Job(self.project.jobs, 1, 'aaa', 2, 3, 4, 5, 60))
예제 #14
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_delete_error(self, m):
     m.delete('https://api-demo.lingo24.com/docs/v1/projects/1/jobs/123',
              status_code=500)
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertRaises(APIError, job.delete)
예제 #15
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_target_file_empty(self):
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, None)
     self.assertIsNone(job.target_file)
예제 #16
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_metrics_error(self, m):
     m.get(
         'https://api-demo.lingo24.com/docs/v1/projects/1/jobs/123/metrics',
         status_code=500)
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertRaises(APIError, lambda: job.metrics)
예제 #17
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_metrics_missing(self, m):
     m.get(
         'https://api-demo.lingo24.com/docs/v1/projects/1/jobs/123/metrics',
         status_code=404)
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertDictEqual(job.metrics, {})
예제 #18
0
파일: jobs.py 프로젝트: RossLote/lingo24
 def test_price_missing(self, m):
     m.get('https://api-demo.lingo24.com/docs/v1/projects/1/jobs/123/price',
           status_code=404)
     job = Job(self.project.jobs, 123, 'aaa', 2, 3, 4, 5, 6)
     self.assertIsNone(job.price)