def test_config_update_exception(self): client = mock.Mock() config = trace_config_pb2.TraceConfig( constant_sampler=trace_config_pb2.ConstantSampler(decision=True)) exporter = TraceExporter(service_name=SERVICE_NAME, client=client, transport=MockTransport) client.Config.side_effect = grpc.RpcError() with self.assertRaises(grpc.RpcError): exporter.update_config(config) client.Config.side_effect = lambda config: iter([config]) exporter.update_config(config) self.assertEqual(len(client.Config.mock_calls), 2) actual_request = list(client.Config.call_args[0][0])[0] self.assertEqual(actual_request.node, exporter.node)
def test_update_config_return_value(self): client = mock.Mock() client_config = trace_config_pb2.TraceConfig( constant_sampler=trace_config_pb2.ConstantSampler(decision=True)) agent_config = trace_config_pb2.TraceConfig( probability_sampler=trace_config_pb2.ProbabilitySampler( samplingProbability=0.1)) exporter = TraceExporter(service_name=SERVICE_NAME, client=client, transport=MockTransport) client.Config.return_value = iter([agent_config]) actual_response = exporter.update_config(client_config) self.assertEqual(actual_response, agent_config)