def get_translate_url(text, target_lang, source_lang=None): """Format URL for translating given test from source to target language.""" query_args = dicts.merge(FIXED_API_PARAMS, { 'sl': source_lang or 'auto', 'tl': target_lang, 'text': text, }) return API_ENDPOINT_URL + '?' + urlencode(query_args)
def test_overwrite__single_arg__dict(self): result = __unit__.merge(self.BASE_DICT, overwrite=False) self.assertEquals(self.BASE_DICT, result) self.assertIsNot(self.BASE_DICT, result)
def test_overwrite__single_arg__none(self): with self.assertRaises(TypeError): __unit__.merge(None, overwrite=False)
def test_deep__two_args__deep_and_shallow(self): result = __unit__.merge(self.DEEP_DICT1, self.NOT_DEEP_DICT, deep=True) self.assertEquals(self.MERGED_DEEP1_AND_NOT_DEEP, result)
def test_deep__two_args__shallow(self): result = __unit__.merge(self.DICT, self.OTHER_DICT, deep=True) self.assertEquals(self.MERGED, result)
def test_deep__single_arg__some_object(self): with self.assertRaises(TypeError): __unit__.merge(object(), deep=True)
def test_deep__no_args(self): with self.assertRaises(TypeError): __unit__.merge(deep=True)
def test_two_args(self): self.assertEquals(self.MERGED, __unit__.merge(self.DICT, self.OTHER_DICT))
def test_deep__single_arg__dict(self): result = __unit__.merge(self.DICT, deep=True) self.assertEquals(self.DICT, result) self.assertIsNot(self.DICT, result)
def test_deep__single_arg__none(self): with self.assertRaises(TypeError): __unit__.merge(None, deep=True)
def test_many_args(self): self.assertEquals( self.MERGED, __unit__.merge(*self.MANY_DICTS))
def test_two_args(self): self.assertEquals( self.MERGED, __unit__.merge(self.DICT, self.OTHER_DICT))
def test_no_args(self): with self.assertRaises(TypeError): __unit__.merge()
def test_many_args(self): self.assertEquals(self.MERGED, __unit__.merge(*self.MANY_DICTS))
def test_deep__two_args__both_deep(self): result = __unit__.merge(self.DEEP_DICT1, self.DEEP_DICT2, deep=True) self.assertEquals(self.MERGED_DEEP_1_2, result)
def test_overwrite__no_args(self): with self.assertRaises(TypeError): __unit__.merge(overwrite=False)
def test_overwrite__single_arg__some_object(self): with self.assertRaises(TypeError): __unit__.merge(object(), overwrite=False)
def test_overwrite__two_args__false(self): self.assertEquals( self.NOT_OVERWRITTEN_DICT, __unit__.merge(self.BASE_DICT, self.OVERWRITING_DICT, overwrite=False))