diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2015-02-12 10:21:39 +0800 |
---|---|---|
committer | Lianhao Lu <lianhao.lu@intel.com> | 2015-02-12 10:21:39 +0800 |
commit | 80b15778beafa2ea52315305cd0c0d0c62aea4ba (patch) | |
tree | 03fd199d113a1405244b2b917d85bf0b2a6e4be6 | |
parent | 0453ac6e8d80db49dcc7a7b07abe27542767bad2 (diff) | |
download | python-ceilometerclient-80b15778beafa2ea52315305cd0c0d0c62aea4ba.tar.gz |
Corrected the errors in sample-show and sample-create
Patchset I67152c636526dad3ec27e06058ff73ad969ae2b9 broke the sample-show
and sample-create when introducing the new sample API support. This
patch fixes those.
Change-Id: I3e36df61cf672b44c376c4a18dc808d565315bf6
Closes-Bug: #1421040
-rw-r--r-- | ceilometerclient/tests/v2/test_shell.py | 10 | ||||
-rw-r--r-- | ceilometerclient/v2/shell.py | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/ceilometerclient/tests/v2/test_shell.py b/ceilometerclient/tests/v2/test_shell.py index 2f13c12..4030439 100644 --- a/ceilometerclient/tests/v2/test_shell.py +++ b/ceilometerclient/tests/v2/test_shell.py @@ -379,6 +379,8 @@ class ShellSampleListCommandTest(utils.BaseTestCase): def setUp(self): super(ShellSampleListCommandTest, self).setUp() self.cc = mock.Mock() + self.cc.samples = mock.Mock() + self.cc.new_samples = mock.Mock() self.args = mock.Mock() self.args.query = None self.args.limit = None @@ -469,16 +471,17 @@ class ShellSampleShowCommandTest(utils.BaseTestCase): def setUp(self): super(ShellSampleShowCommandTest, self).setUp() self.cc = mock.Mock() + self.cc.new_samples = mock.Mock() self.args = mock.Mock() self.args.sample_id = "98b5f258-635e-11e4-8bdd-0025647390c1" @mock.patch('sys.stdout', new=six.StringIO()) def test_sample_show(self): sample = samples.Sample(mock.Mock(), self.SAMPLE) - self.cc.samples.get.return_value = sample + self.cc.new_samples.get.return_value = sample ceilometer_shell.do_sample_show(self.cc, self.args) - self.cc.samples.get.assert_called_once_with( + self.cc.new_samples.get.assert_called_once_with( "98b5f258-635e-11e4-8bdd-0025647390c1") self.assertEqual('''\ @@ -525,6 +528,7 @@ class ShellSampleCreateCommandTest(utils.BaseTestCase): def setUp(self): super(ShellSampleCreateCommandTest, self).setUp() self.cc = mock.Mock() + self.cc.samples = mock.Mock() self.args = mock.Mock() self.args.meter_name = self.METER self.args.meter_type = self.METER_TYPE @@ -536,7 +540,7 @@ class ShellSampleCreateCommandTest(utils.BaseTestCase): def test_sample_create(self): ret_sample = [samples.OldSample(mock.Mock(), sample) for sample in self.SAMPLE] - self.cc.old_samples.create.return_value = ret_sample + self.cc.samples.create.return_value = ret_sample ceilometer_shell.do_sample_create(self.cc, self.args) diff --git a/ceilometerclient/v2/shell.py b/ceilometerclient/v2/shell.py index 3e53b24..67a7646 100644 --- a/ceilometerclient/v2/shell.py +++ b/ceilometerclient/v2/shell.py @@ -169,7 +169,7 @@ def _do_sample_list(cc, args): help='ID (aka message ID) of the sample to show.') def do_sample_show(cc, args): '''Show an sample.''' - sample = cc.samples.get(args.sample_id) + sample = cc.new_samples.get(args.sample_id) if sample is None: raise exc.CommandError('Sample not found: %s' % args.sample_id) @@ -216,7 +216,7 @@ def do_sample_create(cc, args={}): fields[k] = json.loads(v) else: fields[arg_to_field_mapping.get(k, k)] = v - sample = cc.old_samples.create(**fields) + sample = cc.samples.create(**fields) fields = ['counter_name', 'user_id', 'resource_id', 'timestamp', 'message_id', 'source', 'counter_unit', 'counter_volume', 'project_id', 'resource_metadata', |