@@ -122,7 +122,7 @@ def test_invalid_chars_in_constructor(self):
122122
123123 def test_component (self ):
124124 field_path = self ._make_one ('a..b' )
125- self .assertEquals (field_path .parts , ('a..b' ,))
125+ self .assertEqual (field_path .parts , ('a..b' ,))
126126
127127 def test_constructor_iterable (self ):
128128 field_path = self ._make_one ('a' , 'b' , 'c' )
@@ -140,7 +140,7 @@ def test_to_api_repr_a(self):
140140 def test_to_api_repr_backtick (self ):
141141 parts = '`'
142142 field_path = self ._make_one (parts )
143- self .assertEqual (field_path .to_api_repr (), '`\``' )
143+ self .assertEqual (field_path .to_api_repr (), r '`\``' )
144144
145145 def test_to_api_repr_dot (self ):
146146 parts = '.'
@@ -1378,6 +1378,41 @@ def test_field_updates(self):
13781378 self .assertEqual (actual_data , expected_data )
13791379
13801380
1381+ class Test_canonicalize_field_paths (unittest .TestCase ):
1382+
1383+ @staticmethod
1384+ def _call_fut (field_paths ):
1385+ from google .cloud .firestore_v1beta1 import _helpers
1386+
1387+ return _helpers .canonicalize_field_paths (field_paths )
1388+
1389+ def _test_helper (self , to_convert ):
1390+ from google .cloud .firestore_v1beta1 import _helpers
1391+
1392+ paths = [
1393+ _helpers .FieldPath .from_string (path ) for path in to_convert
1394+ ]
1395+ found = self ._call_fut (paths )
1396+
1397+ self .assertEqual (found , sorted (to_convert .values ()))
1398+
1399+ def test_w_native_strings (self ):
1400+ to_convert = {
1401+ '0abc.deq' : '`0abc`.deq' ,
1402+ 'abc.654' : 'abc.`654`' ,
1403+ '321.0deq._321' : '`321`.`0deq`._321' ,
1404+ }
1405+ self ._test_helper (to_convert )
1406+
1407+ def test_w_unicode (self ):
1408+ to_convert = {
1409+ u'0abc.deq' : '`0abc`.deq' ,
1410+ u'abc.654' : 'abc.`654`' ,
1411+ u'321.0deq._321' : '`321`.`0deq`._321' ,
1412+ }
1413+ self ._test_helper (to_convert )
1414+
1415+
13811416class Test_get_transform_pb (unittest .TestCase ):
13821417
13831418 @staticmethod
@@ -1498,24 +1533,6 @@ def test_update_and_transform(self):
14981533 self ._helper (do_transform = True )
14991534
15001535
1501- class Test_canonicalize_field_paths (unittest .TestCase ):
1502-
1503- def test_canonicalize_field_paths (self ):
1504- from google .cloud .firestore_v1beta1 import _helpers
1505-
1506- field_paths = ['0abc.deq' , 'abc.654' , '321.0deq._321' ,
1507- u'0abc.deq' , u'abc.654' , u'321.0deq._321' ]
1508- field_paths = [
1509- _helpers .FieldPath .from_string (path ) for path in field_paths ]
1510- convert = _helpers .canonicalize_field_paths (field_paths )
1511- self .assertListEqual (
1512- convert ,
1513- sorted ([
1514- '`0abc`.deq' , 'abc.`654`' , '`321`.`0deq`._321' ,
1515- '`0abc`.deq' , 'abc.`654`' , '`321`.`0deq`._321' ])
1516- )
1517-
1518-
15191536class Test_pbs_for_update (unittest .TestCase ):
15201537
15211538 @staticmethod
0 commit comments