def test_new_stream_with_source(self):
     chart = Chart(self.conn, 'test')
     stream = chart.new_stream('my.metric', 'prod*')
     self.assertEqual(stream.metric, 'my.metric')
     self.assertEqual(stream.source, 'prod*')
     self.assertEqual(stream.composite, None)
     stream = chart.new_stream(metric='my.metric', source='prod*')
     self.assertEqual(stream.metric, 'my.metric')
     self.assertEqual(stream.source, 'prod*')
     self.assertEqual(stream.composite, None)
 def test_new_stream_defaults(self):
     chart = Chart(self.conn, 'test')
     self.assertEqual(len(chart.streams), 0)
     stream = chart.new_stream('my.metric')
     self.assertIsInstance(stream, Stream)
     self.assertEqual(stream.metric, 'my.metric')
     self.assertEqual(stream.source, '*')
     self.assertEqual(stream.composite, None)
     # Appends to chart streams
     self.assertEqual(len(chart.streams), 1)
     self.assertEqual(chart.streams[0].metric, 'my.metric')
     # Another way to do the same thing
     stream = chart.new_stream(metric='my.metric')
     self.assertEqual(stream.metric, 'my.metric')
 def test_new_stream_with_composite(self):
     chart = Chart(self.conn)
     composite_formula = 's("my.metric", "*")'
     stream = chart.new_stream(composite=composite_formula)
     self.assertIsNone(stream.metric)
     self.assertIsNone(stream.source)
     self.assertEqual(stream.composite, composite_formula)