Esempio n. 1
0
    def test_create_big_number(self):
        # Ensure metrics exist
        self.conn.submit('memory.free', 100)
        # Create space
        space = librato.Space(self.conn, 'my space')
        space.save()
        self.wait_for_replication()
        chart = space.add_chart('memory',
                                type='bignumber',
                                streams=[{
                                    'metric': 'memory.free',
                                    'source': '*'
                                }],
                                use_last_value=False)

        # Shortcut
        chart2 = space.add_bignumber_chart('memory 2',
                                           'memory.free',
                                           'foo*',
                                           use_last_value=True)

        self.wait_for_replication()

        self.assertEqual(chart.type, 'bignumber')
        self.assertEqual(len(chart.streams), 1)
        self.assertFalse(chart.use_last_value)
        self.assertEqual(chart2.type, 'bignumber')
        self.assertEqual(len(chart2.streams), 1)
        self.assertTrue(chart2.use_last_value)
Esempio n. 2
0
 def test_create_chart(self):
     # Ensure metrics exist
     self.conn.submit('memory.free', 100)
     self.conn.submit('memory.used', 200)
     # Create space
     space = librato.Space(self.conn, 'my space')
     space.save()
     # Add chart
     chart = space.add_chart('memory',
                             type='line',
                             streams=[{
                                 'metric': 'memory.free',
                                 'source': '*'
                             }, {
                                 'metric': 'memory.used',
                                 'source': '*',
                                 'group_function': 'breakout',
                                 'summary_function': 'average'
                             }],
                             min=0,
                             max=50,
                             label='the y axis label',
                             use_log_yaxis=True,
                             related_space=1234)
     self.wait_for_replication()
     self.assertEqual(len(chart.streams), 2)
Esempio n. 3
0
 def test_delete_space_via_model(self):
     space = librato.Space(self.conn, 'delete me')
     space.save()
     self.wait_for_replication()
     space.delete()
     self.wait_for_replication()
     self.assertRaises(librato.exceptions.NotFound, self.conn.get_space, space.id)
Esempio n. 4
0
 def test_create_space_via_model(self):
     space = librato.Space(self.conn, 'Production')
     self.assertIsNone(space.id)
     space.save()
     self.assertIsNotNone(space.id)