def test_client_info_user_agent(self): """Check that the monitoring client sets a user agent. The user agent should include the library version. Note that this assumes MetricServiceClient calls ClientInfo.to_user_agent to attach the user agent as metadata to metric service API calls. """ patch_client = mock.patch( 'opencensus.stats.exporters.stackdriver_exporter.monitoring_v3' '.MetricServiceClient', _Client) with patch_client: exporter = stackdriver.new_stats_exporter( stackdriver.Options(project_id=1)) self.assertIn(stackdriver.get_user_agent_slug(), exporter.client.client_info.to_user_agent())
def test_get_user_agent_slug(self): self.assertIn(__version__, stackdriver.get_user_agent_slug())