@@ -86,87 +86,6 @@ def test_completed_key_on_complete(self):
8686 key = self ._makeOne ('KIND' , 1234 )
8787 self .assertRaises (ValueError , key .completed_key , 5678 )
8888
89- def test_compare_to_proto_incomplete_w_id (self ):
90- _ID = 1234
91- key = self ._makeOne ('KIND' )
92- pb = key .to_protobuf ()
93- pb .path_element [0 ].id = _ID
94- new_key = key .compare_to_proto (pb )
95- self .assertFalse (new_key is key )
96- self .assertEqual (new_key .id , _ID )
97- self .assertEqual (new_key .name , None )
98-
99- def test_compare_to_proto_incomplete_w_name (self ):
100- _NAME = 'NAME'
101- key = self ._makeOne ('KIND' )
102- pb = key .to_protobuf ()
103- pb .path_element [0 ].name = _NAME
104- new_key = key .compare_to_proto (pb )
105- self .assertFalse (new_key is key )
106- self .assertEqual (new_key .id , None )
107- self .assertEqual (new_key .name , _NAME )
108-
109- def test_compare_to_proto_incomplete_w_incomplete (self ):
110- key = self ._makeOne ('KIND' )
111- pb = key .to_protobuf ()
112- new_key = key .compare_to_proto (pb )
113- self .assertTrue (new_key is key )
114-
115- def test_compare_to_proto_incomplete_w_bad_path (self ):
116- key = self ._makeOne ('KIND1' , 1234 , 'KIND2' )
117- pb = key .to_protobuf ()
118- pb .path_element [0 ].kind = 'NO_KIND'
119- self .assertRaises (ValueError , key .compare_to_proto , pb )
120-
121- def test_compare_to_proto_complete_w_id (self ):
122- key = self ._makeOne ('KIND' , 1234 )
123- pb = key .to_protobuf ()
124- pb .path_element [0 ].id = 5678
125- self .assertRaises (ValueError , key .compare_to_proto , pb )
126-
127- def test_compare_to_proto_complete_w_name (self ):
128- key = self ._makeOne ('KIND' , 1234 )
129- pb = key .to_protobuf ()
130- pb .path_element [0 ].name = 'NAME'
131- self .assertRaises (ValueError , key .compare_to_proto , pb )
132-
133- def test_compare_to_proto_complete_w_incomplete (self ):
134- key = self ._makeOne ('KIND' , 1234 )
135- pb = key .to_protobuf ()
136- pb .path_element [0 ].ClearField ('id' )
137- self .assertRaises (ValueError , key .compare_to_proto , pb )
138-
139- def test_compare_to_proto_complete_diff_dataset (self ):
140- key = self ._makeOne ('KIND' , 1234 , dataset_id = 'DATASET' )
141- pb = key .to_protobuf ()
142- pb .partition_id .dataset_id = 's~' + key .dataset_id
143- new_key = key .compare_to_proto (pb )
144- self .assertTrue (new_key is key )
145-
146- def test_compare_to_proto_complete_bad_dataset (self ):
147- key = self ._makeOne ('KIND' , 1234 , dataset_id = 'DATASET' )
148- pb = key .to_protobuf ()
149- pb .partition_id .dataset_id = 'BAD_PRE~' + key .dataset_id
150- self .assertRaises (ValueError , key .compare_to_proto , pb )
151-
152- def test_compare_to_proto_complete_valid_namespace (self ):
153- key = self ._makeOne ('KIND' , 1234 , namespace = 'NAMESPACE' )
154- pb = key .to_protobuf ()
155- new_key = key .compare_to_proto (pb )
156- self .assertTrue (new_key is key )
157-
158- def test_compare_to_proto_complete_namespace_unset_on_pb (self ):
159- key = self ._makeOne ('KIND' , 1234 , namespace = 'NAMESPACE' )
160- pb = key .to_protobuf ()
161- pb .partition_id .ClearField ('namespace' )
162- self .assertRaises (ValueError , key .compare_to_proto , pb )
163-
164- def test_compare_to_proto_complete_namespace_unset_on_key (self ):
165- key = self ._makeOne ('KIND' , 1234 )
166- pb = key .to_protobuf ()
167- pb .partition_id .namespace = 'NAMESPACE'
168- self .assertRaises (ValueError , key .compare_to_proto , pb )
169-
17089 def test_to_protobuf_defaults (self ):
17190 from gcloud .datastore .datastore_v1_pb2 import Key as KeyPB
17291 _KIND = 'KIND'
0 commit comments