From 97be8176973e8088a292ee43263c8ce117d7a5d3 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 15 Mar 2016 11:46:51 -0400 Subject: [PATCH] Add system test for 'Client.metric'/'Metric.create'. --- system_tests/logging_.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/system_tests/logging_.py b/system_tests/logging_.py index 9b3e99a453b7..a4072bc65ab8 100644 --- a/system_tests/logging_.py +++ b/system_tests/logging_.py @@ -21,7 +21,10 @@ from gcloud import logging -DEFAULT_LOGGER_NAME = 'system-tests-%d' % (1000 * time.time(),) +DEFAULT_LOGGER_NAME = 'system-tests-logger-%d' % (1000 * time.time(),) +DEFAULT_METRIC_NAME = 'system-tests-metric-%d' % (1000 * time.time(),) +DEFAULT_FILTER = 'logName:syslog AND severity>=INFO' +DEFAULT_DESCRIPTION = 'System testing' class Config(object): @@ -69,3 +72,11 @@ def test_log_struct(self): entries, _ = logger.list_entries() self.assertEqual(len(entries), 1) self.assertEqual(entries[0].payload, JSON_PAYLOAD) + + def test_create_metric(self): + metric = Config.CLIENT.metric( + DEFAULT_METRIC_NAME, DEFAULT_FILTER, DEFAULT_DESCRIPTION) + self.assertFalse(metric.exists()) + metric.create() + self.to_delete.append(metric) + self.assertTrue(metric.exists())