class TestLanguageServiceMethods(unittest.TestCase): """ Tests the methods that deal with getting information about language- translation service support from Gengo. """ def setUp(self): self.gengo = Gengo(public_key=API_PUBKEY, private_key=API_PRIVKEY, sandbox=True) from gengo import requests self.json_mock = mock.Mock() self.json_mock.json.return_value = {"opstat": "ok"} self.getMock = RequestsMock(return_value=self.json_mock) self.requestsPatch = mock.patch.object(requests, "get", self.getMock) self.requestsPatch.start() def tearDown(self): self.requestsPatch.stop() def test_getServiceLanguagePairs(self): resp = self.gengo.getServiceLanguagePairs() self.assertEqual(resp["opstat"], "ok") self.getMock.assert_path_contains(mockdb.apihash["getServiceLanguagePairs"]["url"]) def test_getServiceLanguages(self): resp = self.gengo.getServiceLanguages() self.assertEqual(resp["opstat"], "ok") self.getMock.assert_path_contains(mockdb.apihash["getServiceLanguages"]["url"]) def test_getServiceLanguageMatrix(self): resp = self.gengo.getServiceLanguageMatrix() self.assertEqual(resp["opstat"], "ok") self.getMock.assert_path_contains(mockdb.apihash["getServiceLanguageMatrix"]["url"])
class TestLanguageServiceMethods(unittest.TestCase): """ Tests the methods that deal with getting information about language- translation service support from Gengo. """ def setUp(self): self.gengo = Gengo(public_key=API_PUBKEY, private_key=API_PRIVKEY) self.gengo.api_url = 'http://api.staging.gengo.com/%(version)s' def test_getServiceLanguagePairs(self): resp = self.gengo.getServiceLanguagePairs() self.assertEqual(resp['opstat'], 'ok') def test_getServiceLanguages(self): resp = self.gengo.getServiceLanguages() self.assertEqual(resp['opstat'], 'ok')
class TestLanguageServiceMethods(unittest.TestCase): """ Tests the methods that deal with getting information about language- translation service support from Gengo. """ def setUp(self): self.gengo = Gengo(public_key=API_PUBKEY, private_key=API_PRIVKEY, sandbox=True) def test_getServiceLanguagePairs(self): resp = self.gengo.getServiceLanguagePairs() self.assertEqual(resp['opstat'], 'ok') def test_getServiceLanguages(self): resp = self.gengo.getServiceLanguages() self.assertEqual(resp['opstat'], 'ok')
class TestLanguageServiceMethods(unittest.TestCase): """ Tests the methods that deal with getting information about language- translation service support from Gengo. """ def setUp(self): self.gengo = Gengo(public_key=API_PUBKEY, private_key=API_PRIVKEY, sandbox=True) from gengo import requests self.json_mock = mock.Mock() self.json_mock.json.return_value = {'opstat': 'ok'} self.getMock = RequestsMock(return_value=self.json_mock) self.requestsPatch = mock.patch.object(requests, 'get', self.getMock) self.requestsPatch.start() def tearDown(self): self.requestsPatch.stop() def test_getServiceLanguagePairs(self): resp = self.gengo.getServiceLanguagePairs() self.assertEqual(resp['opstat'], 'ok') self.getMock.assert_path_contains( mockdb.apihash['getServiceLanguagePairs']['url']) def test_getServiceLanguages(self): resp = self.gengo.getServiceLanguages() self.assertEqual(resp['opstat'], 'ok') self.getMock.assert_path_contains( mockdb.apihash['getServiceLanguages']['url']) def test_getServiceLanguageMatrix(self): resp = self.gengo.getServiceLanguageMatrix() self.assertEqual(resp['opstat'], 'ok') self.getMock.assert_path_contains( mockdb.apihash['getServiceLanguageMatrix']['url'])
class TestLanguageServiceMethods(unittest.TestCase): """ Tests the methods that deal with getting information about language- translation service support from Gengo. """ def setUp(self): self.gengo = Gengo(public_key=API_PUBKEY, private_key=API_PRIVKEY, sandbox=True) self.json_mock = mock.Mock() self.json_mock.json.return_value = {'opstat': 'ok'} self.getMock = RequestsMock(return_value=self.json_mock) self.requestsPatch = mock.patch.object(requests, 'get', self.getMock) self.requestsPatch.start() def tearDown(self): self.requestsPatch.stop() def test_getServiceLanguagePairs(self): resp = self.gengo.getServiceLanguagePairs() self.assertEqual(resp['opstat'], 'ok') self.getMock.assert_path_contains( gengo.mockdb.apihash['getServiceLanguagePairs']['url']) def test_getServiceLanguages(self): resp = self.gengo.getServiceLanguages() self.assertEqual(resp['opstat'], 'ok') self.getMock.assert_path_contains( gengo.mockdb.apihash['getServiceLanguages']['url']) def test_getServiceLanguageMatrix(self): resp = self.gengo.getServiceLanguageMatrix() self.assertEqual(resp['opstat'], 'ok') self.getMock.assert_path_contains( gengo.mockdb.apihash['getServiceLanguageMatrix']['url'])
# Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # Neither the name of myGengo, Inc. nor the names of its contributors may # be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from gengo import Gengo from pprint import pprint gengo = Gengo( public_key='your public key', private_key='your private key', sandbox=False, ) # Pretty-print a list of every supported language pprint(gengo.getServiceLanguages())