@@ -68,7 +68,7 @@ def test_create_w_alternate_client(self):
6868 'filter' : self .FILTER ,
6969 'destination' : self .DESTINATION_URI ,
7070 }
71- conn1 = _Connection ({ 'name' : FULL } )
71+ conn1 = _Connection ()
7272 client1 = _Client (project = self .PROJECT , connection = conn1 )
7373 conn2 = _Connection ({'name' : FULL })
7474 client2 = _Client (project = self .PROJECT , connection = conn2 )
@@ -96,7 +96,7 @@ def test_exists_miss_w_bound_client(self):
9696
9797 def test_exists_hit_w_alternate_client (self ):
9898 FULL = 'projects/%s/sinks/%s' % (self .PROJECT , self .SINK_NAME )
99- conn1 = _Connection ({ 'name' : FULL } )
99+ conn1 = _Connection ()
100100 CLIENT1 = _Client (project = self .PROJECT , connection = conn1 )
101101 conn2 = _Connection ({'name' : FULL })
102102 CLIENT2 = _Client (project = self .PROJECT , connection = conn2 )
@@ -109,6 +109,51 @@ def test_exists_hit_w_alternate_client(self):
109109 self .assertEqual (req ['method' ], 'GET' )
110110 self .assertEqual (req ['path' ], '/%s' % FULL )
111111
112+ def test_reload_w_bound_client (self ):
113+ FULL = 'projects/%s/sinks/%s' % (self .PROJECT , self .SINK_NAME )
114+ NEW_FILTER = 'logName:syslog AND severity>=INFO'
115+ NEW_DESTINATION_URI = 'faux.googleapis.com/other'
116+ RESOURCE = {
117+ 'name' : self .SINK_NAME ,
118+ 'filter' : NEW_FILTER ,
119+ 'destination' : NEW_DESTINATION_URI ,
120+ }
121+ conn = _Connection (RESOURCE )
122+ CLIENT = _Client (project = self .PROJECT , connection = conn )
123+ sink = self ._makeOne (self .SINK_NAME , self .FILTER , self .DESTINATION_URI ,
124+ client = CLIENT )
125+ sink .reload ()
126+ self .assertEqual (sink .filter_ , NEW_FILTER )
127+ self .assertEqual (sink .destination , NEW_DESTINATION_URI )
128+ self .assertEqual (len (conn ._requested ), 1 )
129+ req = conn ._requested [0 ]
130+ self .assertEqual (req ['method' ], 'GET' )
131+ self .assertEqual (req ['path' ], '/%s' % FULL )
132+
133+ def test_reload_w_alternate_client (self ):
134+ FULL = 'projects/%s/sinks/%s' % (self .PROJECT , self .SINK_NAME )
135+ NEW_FILTER = 'logName:syslog AND severity>=INFO'
136+ NEW_DESTINATION_URI = 'faux.googleapis.com/other'
137+ RESOURCE = {
138+ 'name' : self .SINK_NAME ,
139+ 'filter' : NEW_FILTER ,
140+ 'destination' : NEW_DESTINATION_URI ,
141+ }
142+ conn1 = _Connection ()
143+ CLIENT1 = _Client (project = self .PROJECT , connection = conn1 )
144+ conn2 = _Connection (RESOURCE )
145+ CLIENT2 = _Client (project = self .PROJECT , connection = conn2 )
146+ sink = self ._makeOne (self .SINK_NAME , self .FILTER , self .DESTINATION_URI ,
147+ client = CLIENT1 )
148+ sink .reload (client = CLIENT2 )
149+ self .assertEqual (sink .filter_ , NEW_FILTER )
150+ self .assertEqual (sink .destination , NEW_DESTINATION_URI )
151+ self .assertEqual (len (conn1 ._requested ), 0 )
152+ self .assertEqual (len (conn2 ._requested ), 1 )
153+ req = conn2 ._requested [0 ]
154+ self .assertEqual (req ['method' ], 'GET' )
155+ self .assertEqual (req ['path' ], '/%s' % FULL )
156+
112157
113158class _Connection (object ):
114159
0 commit comments