Merge lp:~james-page/charm-helpers/assertRaises into lp:~xfactor973/charm-helpers/ceph-functions

Proposed by James Page
Status: Merged
Merge reported by: James Page
Merged at revision: not available
Proposed branch: lp:~james-page/charm-helpers/assertRaises
Merge into: lp:~xfactor973/charm-helpers/ceph-functions
Diff against target: 104 lines (+23/-21)
1 file modified
tests/contrib/storage/test_linux_ceph.py (+23/-21)
To merge this branch: bzr merge lp:~james-page/charm-helpers/assertRaises
Reviewer Review Type Date Requested Status
Chris Holcombe Approve
Review via email: mp+279990@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Chris Holcombe (xfactor973) wrote :

+1 Looks great

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/contrib/storage/test_linux_ceph.py'
2--- tests/contrib/storage/test_linux_ceph.py 2015-11-18 18:11:49 +0000
3+++ tests/contrib/storage/test_linux_ceph.py 2015-12-09 10:12:57 +0000
4@@ -1,4 +1,3 @@
5-import unittest
6 from mock import patch, call
7
8 import six
9@@ -33,7 +32,7 @@
10 baz
11 """
12 # Vastly abbreviated output from ceph osd dump --format=json
13-OSD_DUMP = b"""
14+OSD_DUMP = """
15 {
16 "pools": [
17 {
18@@ -153,19 +152,19 @@
19 valid_type=int,
20 valid_range=[0, 2])
21
22- @unittest.expectedFailure
23 def test_validator_invalid_range(self):
24 # 1 is an int that isn't in the valid list of only 0
25- ceph_utils.validator(value=1,
26- valid_type=int,
27- valid_range=[0])
28+ self.assertRaises(ValueError, ceph_utils.validator,
29+ value=1,
30+ valid_type=int,
31+ valid_range=[0])
32
33- @unittest.expectedFailure
34 def test_validator_invalid_string_list(self):
35 # foo is a six.string_types that isn't in the valid string list
36- ceph_utils.validator(value="foo",
37- valid_type=six.string_types,
38- valid_range=["valid", "list", "of", "strings"])
39+ self.assertRaises(AssertionError, ceph_utils.validator,
40+ value="foo",
41+ valid_type=six.string_types,
42+ valid_range=["valid", "list", "of", "strings"])
43
44 def test_pool_add_cache_tier(self):
45 p = ceph_utils.Pool(name='test', service='admin')
46@@ -251,11 +250,11 @@
47 call(['ceph', '--id', 'admin', 'osd', 'pool', 'create', 'test', str(65536)]),
48 ])
49
50- @unittest.expectedFailure
51 def test_replicated_pool_create_failed(self):
52- self.check_call.side_effect = CalledProcessError
53+ self.check_call.side_effect = CalledProcessError(returncode=1, cmd='mock',
54+ output=None)
55 p = ceph_utils.ReplicatedPool(name='test', service='admin', replicas=3)
56- p.create()
57+ self.assertRaises(CalledProcessError, p.create)
58
59 @patch.object(ceph_utils, 'pool_exists')
60 def test_replicated_pool_skips_creation(self, pool_exists):
61@@ -264,10 +263,11 @@
62 p.create()
63 self.check_call.assert_has_calls([])
64
65- @unittest.expectedFailure
66 def test_erasure_pool_create_failed(self):
67+ self.check_output.side_effect = CalledProcessError(returncode=1, cmd='ceph',
68+ output=None)
69 p = ceph_utils.ErasurePool(name='test', service='admin', erasure_code_profile='foo')
70- p.create()
71+ self.assertRaises(ceph_utils.PoolCreationError, p.create)
72
73 @patch.object(ceph_utils, 'get_erasure_profile')
74 @patch.object(ceph_utils, 'get_osds')
75@@ -298,10 +298,11 @@
76 call(['ceph', '--id', 'admin', 'osd', 'pool', 'set', 'data', 'test', 2])
77 )
78
79- @unittest.expectedFailure
80 def test_pool_set_fails(self):
81- self.check_call.side_effect = CalledProcessError
82- ceph_utils.pool_set(service='admin', pool_name='data', key='test', value=2)
83+ self.check_call.side_effect = CalledProcessError(returncode=1, cmd='mock',
84+ output=None)
85+ self.assertRaises(CalledProcessError, ceph_utils.pool_set,
86+ service='admin', pool_name='data', key='test', value=2)
87
88 def test_snapshot_pool(self):
89 self.check_call.return_value = 0
90@@ -310,10 +311,11 @@
91 call(['ceph', '--id', 'admin', 'osd', 'pool', 'mksnap', 'data', 'test-snap-1'])
92 )
93
94- @unittest.expectedFailure
95 def test_snapshot_pool_fails(self):
96- self.check_call.side_effect = CalledProcessError
97- ceph_utils.snapshot_pool(service='admin', pool_name='data', snapshot_name='test-snap-1')
98+ self.check_call.side_effect = CalledProcessError(returncode=1, cmd='mock',
99+ output=None)
100+ self.assertRaises(CalledProcessError, ceph_utils.snapshot_pool,
101+ service='admin', pool_name='data', snapshot_name='test-snap-1')
102
103 def test_remove_pool_snapshot(self):
104 self.check_call.return_value = 0

Subscribers

People subscribed via source and target branches

to all changes: