本文整理汇总了Python中mygengo.MyGengo.getTranslationOrderJobs方法的典型用法代码示例。如果您正苦于以下问题:Python MyGengo.getTranslationOrderJobs方法的具体用法?Python MyGengo.getTranslationOrderJobs怎么用?Python MyGengo.getTranslationOrderJobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygengo.MyGengo
的用法示例。
在下文中一共展示了MyGengo.getTranslationOrderJobs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTranslationJobFlowMixedOrder
# 需要导入模块: from mygengo import MyGengo [as 别名]
# 或者: from mygengo.MyGengo import getTranslationOrderJobs [as 别名]
class TestTranslationJobFlowMixedOrder(unittest.TestCase):
"""
Tests the flow of creating a job, updating it, getting the details, and then
deleting the job for an order with mixed file/text jobs.
Flow is as follows:
1: Create a mock job and get an estimate for it (setUp)
2: Create three jobs - 1 single, 2 batched
3: Update the first job with some arbitrary information or something
4: Post a comment on the first job
6: Perform a hell of a lot of GETs to the Gengo API to check stuff
7: Delete the job if all went well (teardown phase)
"""
def setUp(self):
"""
Creates the initial batch of jobs for the other test functions here to operate on.
"""
# First we'll create three jobs - one regular, and two at the same time...
self.myGengo = MyGengo(public_key = public_key, private_key = private_key, api_version = '2', sandbox = SANDBOX)
self.created_job_ids = []
multiple_jobs_quote = {
'job_1': {
'type': 'file',
'file_path': './examples/testfiles/test_file1.txt',
'lc_src': 'en',
'lc_tgt': 'ja',
'tier': 'standard',
},
'job_2': {
'type': 'text',
'body_src': 'Liverpool Football Club is an English Premier League football club based in Liverpool, Merseyside. Liverpool is awesome and is the best club around. Liverpool was founded in 1892 and admitted into the Football League the following year. The club has played at its home ground, Anfield, since its founding, and the team has played in an all-red home strip since 1964. Domestically, Liverpool has won eighteen league titles - the second most in English football - as well as seven FA Cups, a record eight League Cups and fifteen FA Community Shields. Liverpool has also won more European titles than any other English club, with five European Cups, three UEFA Cups and three UEFA Super Cups. The most successful period in Liverpool',
'lc_src': 'en',
'lc_tgt': 'ja',
'tier': 'standard',
},
}
# Now that we've got the job, let's go ahead and see how much it'll cost.
cost_assessment = self.myGengo.determineTranslationCost(jobs = {'jobs': multiple_jobs_quote})
self.assertEqual(cost_assessment['opstat'], 'ok')
multiple_jobs = {}
for k, j in cost_assessment['response']['jobs'].iteritems():
if j['type'] == 'file':
multiple_jobs[k] = {
'type': 'file',
'identifier': j['identifier'],
'comment': 'Test comment for filejob %s' % (k,),
'glossary_id': None,
'use_preferred': 0,
'force': 1
}
else:
multiple_jobs[k] = multiple_jobs_quote[k]
multiple_jobs[k]['comment'] = 'Test comment for textjob %s' % (k,)
multiple_jobs[k]['glossary_id'] = None
multiple_jobs[k]['use_preferred'] = 0
multiple_jobs[k]['force'] = 1
jobs = self.myGengo.postTranslationJobs(jobs = {'jobs': multiple_jobs})
self.assertEqual(jobs['opstat'], 'ok')
self.assertTrue('order_id' in jobs['response'])
self.assertTrue('credits_used' in jobs['response'])
self.assertEqual(jobs['response']['job_count'], 2)
# get some order information - in v2 the jobs need to have gone through a
# queueing system so we wait a little bit
time.sleep( 30 )
resp = self.myGengo.getTranslationOrderJobs(id = jobs['response']['order_id'])
self.assertEqual(len(resp['response']['order']['jobs_available']), 2)
self.created_job_ids.extend(resp['response']['order']['jobs_available'])
@unittest.skip("We don't test Gengo.getTranslationJobPreviewImage() because it's potentially resource heavy on the Gengo API.")
def test_getTranslationJobPreviewImage(self):
"""
This test could be a bit more granular, but I'm undecided at the moment - testing the response stream
of this method is more of a Unit Test for Gengo than Gengo. Someone can extend if they see fit, but I
currently see no reason to mess with this further.
"""
img = self.myGengo.getTranslationJobPreviewImage(id = self.created_job_ids[0])
self.assertIsNotNone(img)
def test_postJobDataMethods(self):
"""
Tests all the Gengo methods that deal with updating jobs, posting comments, etc. test_getJobDataMethods() checks things,
but they need to exist first - think of this as the alcoholic mother to _getJobDataMethods().
"""
# The 'update' method can't really be tested, as it requires the translator having actually done something before
# it's of any use. Thing is, in automated testing, we don't really have a method to flip the switch on the Gengo end. If we
# WERE to test this method, it'd look a little something like this:
#
# updated_job = self.myGengo.updateTranslationJob(id = self.created_job_ids[0], action = {
# 'action': 'purchase',
# })
# self.assertEqual(updated_job['opstat'], 'ok')
posted_comment = self.myGengo.postTranslationJobComment(id = self.created_job_ids[0], comment = {
#.........这里部分代码省略.........