Пример #1
0
 def test__list_resources(self, mock_clients):
     """Test _list_resources."""
     fake_resources = []
     mock_clients("ceilometer").resources.list.return_value = fake_resources
     scenario = utils.CeilometerScenario()
     resources = scenario._list_resources()
     self.assertEqual(fake_resources, resources)
Пример #2
0
 def test__get_stats(self, mock_clients):
     """Test _get_stats function."""
     fake_stats = mock.MagicMock()
     mock_clients("ceilometer").statistics.list.return_value = fake_stats
     scenario = utils.CeilometerScenario()
     stats = scenario._get_stats("fake_name")
     self.assertEqual(fake_stats, stats)
Пример #3
0
 def test__update_alarms(self, mock_clients):
     """Test if call to alarms.update is made to ensure alarm is updated."""
     fake_alarm_dict_diff = {"description": "Changed Test Description"}
     scenario = utils.CeilometerScenario()
     scenario._update_alarm("FAKE_ALARM_ID", fake_alarm_dict_diff)
     mock_clients("ceilometer").alarms.update.assert_called_once_with(
         "FAKE_ALARM_ID", **fake_alarm_dict_diff)
Пример #4
0
 def test__list_meters(self, mock_clients):
     """Test _list_meters."""
     fake_meters = []
     mock_clients("ceilometer").meters.list.return_value = fake_meters
     scenario = utils.CeilometerScenario()
     meters = scenario._list_meters()
     self.assertEqual(fake_meters, meters)
Пример #5
0
 def test__list_alarms(self, mock_clients):
     """Test _list_alarms when no alarm_id is passed to it."""
     fake_alarms = []
     mock_clients("ceilometer").alarms.list.return_value = fake_alarms
     scenario = utils.CeilometerScenario()
     alarms = scenario._list_alarms()
     self.assertEqual(fake_alarms, alarms)
Пример #6
0
 def test__list_alarm(self, mock_clients):
     """Test _list_alarms when alarm_id is passed to it."""
     fake_alarms = ['fake_alarm']
     mock_clients("ceilometer").alarms.get.return_value = fake_alarms
     scenario = utils.CeilometerScenario()
     alarms = scenario._list_alarms("FAKE_ALARM_ID")
     self.assertEqual(fake_alarms, alarms)
Пример #7
0
 def test__query_samples(self, mock_clients):
     mock_client = mock_clients("ceilometer")
     mock_client.query_samples.query = mock.MagicMock()
     scenario = utils.CeilometerScenario()
     scenario._query_samples("fake_filter", "fake_orderby_attribute", 10)
     mock_client.query_samples.query.assert_called_once_with(
         "fake_filter", "fake_orderby_attribute", 10)
Пример #8
0
 def test__create_meter(self, mock_clients):
     """Test _create_meter returns meter."""
     fake_meter = mock.MagicMock()
     kwargs = mock.MagicMock()
     mock_clients("ceilometer").samples.create.return_value = [fake_meter]
     scenario = utils.CeilometerScenario()
     created_meter = scenario._create_meter(**kwargs)
     self.assertEqual(fake_meter, created_meter)
Пример #9
0
 def test__create_alarm(self, mock_clients):
     """Test _create_alarm returns alarm."""
     fake_alarm = mock.MagicMock()
     fake_alarm_dict = dict()
     mock_clients("ceilometer").alarms.create.return_value = fake_alarm
     scenario = utils.CeilometerScenario()
     created_alarm = scenario._create_alarm("fake_meter_name",
                                            "fake_threshold",
                                            fake_alarm_dict)
     self.assertEqual(fake_alarm, created_alarm)
Пример #10
0
 def setUp(self):
     super(CeilometerScenarioTestCase, self).setUp()
     self.scenario = utils.CeilometerScenario()
     self.scenario.clients = mock.MagicMock(
         return_value=fakes.FakeCeilometerClient())
     self.res_is = mockpatch.Patch(BM_UTILS + ".resource_is")
     self.get_fm = mockpatch.Patch(BM_UTILS + ".get_from_manager")
     self.wait_for = mockpatch.Patch(CEILOMETER_UTILS +
                                     ".bench_utils.wait_for")
     self.useFixture(self.wait_for)
     self.useFixture(self.res_is)
     self.useFixture(self.get_fm)
     self.gfm = self.get_fm.mock
Пример #11
0
 def test__create_sample(self, mock_clients):
     """Test _create_sample returns sample."""
     fake_sample = mock.MagicMock()
     fake_sample_dict = dict()
     mock_clients("ceilometer").samples.create.return_value = fake_sample
     scenario = utils.CeilometerScenario()
     created_sample = scenario._create_sample("fake_counter_name",
                                              "fake_counter_type",
                                              "fake_counter_unit",
                                              "fake_counter_volume",
                                              "fake_resource_id",
                                              **fake_sample_dict)
     self.assertEqual(fake_sample, created_sample)
Пример #12
0
 def setUp(self):
     super(CeilometerScenarioTestCase, self).setUp()
     self.scenario = utils.CeilometerScenario()
     self.scenario.clients = mock.MagicMock(
         return_value=fakes.FakeCeilometerClient())
Пример #13
0
 def test__delete_alarms(self, mock_clients):
     """Test if call to alarms.delete is made to ensure alarm is deleted."""
     scenario = utils.CeilometerScenario()
     scenario._delete_alarm("FAKE_ALARM_ID")
     mock_clients("ceilometer").alarms.delete.assert_called_once_with(
         "FAKE_ALARM_ID")