Пример #1
0
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)
Пример #2
0
 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)
Пример #3
0
 def test_overwrite__single_arg__none(self):
     with self.assertRaises(TypeError):
         __unit__.merge(None, overwrite=False)
Пример #4
0
 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)
Пример #5
0
 def test_deep__two_args__shallow(self):
     result = __unit__.merge(self.DICT, self.OTHER_DICT, deep=True)
     self.assertEquals(self.MERGED, result)
Пример #6
0
 def test_deep__single_arg__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.merge(object(), deep=True)
Пример #7
0
 def test_deep__no_args(self):
     with self.assertRaises(TypeError):
         __unit__.merge(deep=True)
Пример #8
0
 def test_two_args(self):
     self.assertEquals(self.MERGED,
                       __unit__.merge(self.DICT, self.OTHER_DICT))
Пример #9
0
 def test_deep__single_arg__dict(self):
     result = __unit__.merge(self.DICT, deep=True)
     self.assertEquals(self.DICT, result)
     self.assertIsNot(self.DICT, result)
Пример #10
0
 def test_deep__single_arg__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.merge(object(), deep=True)
Пример #11
0
 def test_deep__single_arg__none(self):
     with self.assertRaises(TypeError):
         __unit__.merge(None, deep=True)
Пример #12
0
 def test_deep__no_args(self):
     with self.assertRaises(TypeError):
         __unit__.merge(deep=True)
Пример #13
0
 def test_many_args(self):
     self.assertEquals(
         self.MERGED, __unit__.merge(*self.MANY_DICTS))
Пример #14
0
 def test_two_args(self):
     self.assertEquals(
         self.MERGED, __unit__.merge(self.DICT, self.OTHER_DICT))
Пример #15
0
 def test_no_args(self):
     with self.assertRaises(TypeError):
         __unit__.merge()
Пример #16
0
 def test_no_args(self):
     with self.assertRaises(TypeError):
         __unit__.merge()
Пример #17
0
 def test_deep__two_args__shallow(self):
     result = __unit__.merge(self.DICT, self.OTHER_DICT, deep=True)
     self.assertEquals(self.MERGED, result)
Пример #18
0
 def test_many_args(self):
     self.assertEquals(self.MERGED, __unit__.merge(*self.MANY_DICTS))
Пример #19
0
 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)
Пример #20
0
 def test_deep__single_arg__none(self):
     with self.assertRaises(TypeError):
         __unit__.merge(None, deep=True)
Пример #21
0
 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)
Пример #22
0
 def test_deep__single_arg__dict(self):
     result = __unit__.merge(self.DICT, deep=True)
     self.assertEquals(self.DICT, result)
     self.assertIsNot(self.DICT, result)
Пример #23
0
 def test_overwrite__no_args(self):
     with self.assertRaises(TypeError):
         __unit__.merge(overwrite=False)
Пример #24
0
 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)
Пример #25
0
 def test_overwrite__single_arg__none(self):
     with self.assertRaises(TypeError):
         __unit__.merge(None, overwrite=False)
Пример #26
0
 def test_overwrite__no_args(self):
     with self.assertRaises(TypeError):
         __unit__.merge(overwrite=False)
Пример #27
0
 def test_overwrite__single_arg__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.merge(object(), overwrite=False)
Пример #28
0
 def test_overwrite__single_arg__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.merge(object(), overwrite=False)
Пример #29
0
 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)
Пример #30
0
 def test_overwrite__two_args__false(self):
     self.assertEquals(
         self.NOT_OVERWRITTEN_DICT,
         __unit__.merge(self.BASE_DICT,
                        self.OVERWRITING_DICT,
                        overwrite=False))
Пример #31
0
 def test_overwrite__two_args__false(self):
     self.assertEquals(
         self.NOT_OVERWRITTEN_DICT,
         __unit__.merge(self.BASE_DICT, self.OVERWRITING_DICT,
                        overwrite=False))