Skip to content

Commit 9ded7ac

Browse files
committed
Organize the python code conform with standards, done for unittests
1 parent cb18687 commit 9ded7ac

6 files changed

Lines changed: 25 additions & 16 deletions

File tree

oca/tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ def test_default_user_path(self):
3939
@raises(oca.OpenNebulaException)
4040
def test_wrong_default_user_path(self):
4141
oca.Client.DEFAULT_ONE_AUTH = '/ad/ads/a/das/d/sad/sad/sa/d/one_auth'
42-
c = oca.Client()
42+
oca.Client()
4343

4444
@raises(oca.OpenNebulaException)
4545
def test_invalid_secret(self):
4646
os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__),
4747
'tests/fixtures/one_auth')
48-
c = oca.Client('testtest')
48+
oca.Client('testtest')
4949

5050
def test_addres(self):
5151
c = oca.Client('test:test', "http://8.8.8.8:2633/RPC2")

oca/tests/test_datastore_pool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
class TestDatastorePool(unittest.TestCase):
1111
def setUp(self):
1212
self.client = oca.Client('test:test')
13-
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
14-
'tests/fixtures/datastorepool.xml')).read()
13+
self.xml = open(
14+
os.path.join(os.path.dirname(oca.__file__),
15+
'tests/fixtures/datastorepool.xml')).read()
1516

1617
def test_info(self):
1718
self.client.call = Mock(return_value=self.xml)

oca/tests/test_host.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def test_states(self):
3636
h = oca.Host('<HOST><ID>2</ID><STATE>{0}</STATE></HOST>'.format(i),
3737
self.client)
3838
assert h.str_state == oca.Host.HOST_STATES[i]
39-
assert h.short_state == oca.Host.SHORT_HOST_STATES[oca.Host.HOST_STATES[i]]
39+
assert h.short_state == oca.Host.SHORT_HOST_STATES[
40+
oca.Host.HOST_STATES[i]]
4041

4142
def test_repr(self):
4243
h = oca.Host(self.xml, self.client)

oca/tests/test_image.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def setUp(self):
2323

2424
def test_allocate(self):
2525
self.client.call = Mock(return_value=2)
26-
assert oca.Image.allocate(self.client, IMAGE_TEMPLATE, DEFAULT_IMG_DATASTORE) == 2
26+
assert oca.Image.allocate(
27+
self.client, IMAGE_TEMPLATE, DEFAULT_IMG_DATASTORE) == 2
2728

2829
def test_enable(self):
2930
self.client.call = Mock(return_value='')
@@ -74,7 +75,8 @@ def test_states(self):
7475
h = oca.Image('<IMAGE><ID>2</ID><STATE>%s</STATE></IMAGE>' % i,
7576
self.client)
7677
assert h.str_state == oca.Image.IMAGE_STATES[i]
77-
short_image_state = oca.Image.SHORT_IMAGE_STATES[oca.Image.IMAGE_STATES[i]]
78+
short_image_state = oca.Image.SHORT_IMAGE_STATES[
79+
oca.Image.IMAGE_STATES[i]]
7880
assert h.short_state == short_image_state
7981

8082
def test_repr(self):
@@ -86,7 +88,8 @@ def test_types(self):
8688
h = oca.Image('<IMAGE><ID>2</ID><TYPE>%s</TYPE></IMAGE>' % i,
8789
self.client)
8890
assert h.str_type == oca.Image.IMAGE_TYPES[i]
89-
short_image_type = oca.Image.SHORT_IMAGE_TYPES[oca.Image.IMAGE_TYPES[i]]
91+
short_image_type = oca.Image.SHORT_IMAGE_TYPES[
92+
oca.Image.IMAGE_TYPES[i]]
9093
assert h.short_type == short_image_type
9194

9295
def test_template(self):
@@ -105,5 +108,5 @@ def test_chmod(self):
105108
self.client.call = Mock(return_value='')
106109
h = oca.Image(self.xml, self.client)
107110
h.chmod(1, 0, 0, -1, -1, -1, -1, -1, -1)
108-
self.client.call.assert_called_once_with('image.chmod',
109-
'1', 1, 0, 0, -1, -1, -1, -1, -1, -1)
111+
self.client.call.assert_called_once_with(
112+
'image.chmod', '1', 1, 0, 0, -1, -1, -1, -1, -1, -1)

oca/tests/test_virtual_network.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def test_address_ranges(self):
5656
assert (2 == len(h.address_ranges))
5757
assert (1 == h.address_ranges[1].id)
5858
assert (0 == h.address_ranges[0].id)
59-
assert (" 0 68719479930 1 68719545020" == h.address_ranges[0].allocated)
59+
assert (" 0 68719479930 1 68719545020" ==
60+
h.address_ranges[0].allocated)
6061
assert ("10.1.0.10" == h.address_ranges[0].ip)
6162
assert ("00:22:44:66:88:aa" == h.address_ranges[0].mac)
6263
assert (507 == h.address_ranges[0].size)

oca/tests/test_virtualmachine.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ def test_save_disk(self):
9090
def test_actions(self):
9191
oca.client = oca.Client('test:test')
9292
vm = oca.VirtualMachine(self.xml, self.client)
93-
for action in ['shutdown', 'shutdown_hard', 'poweroff', 'poweroff_hard',
94-
'hold', 'release', 'stop', 'cancel', 'suspend', 'resume',
95-
'reboot', 'finalize', 'delete', 'resched', 'unresched']:
93+
for action in ['shutdown', 'shutdown_hard', 'poweroff',
94+
'poweroff_hard', 'hold', 'release', 'stop', 'cancel',
95+
'suspend', 'resume', 'reboot', 'finalize', 'delete',
96+
'resched', 'unresched']:
9697
self.client.call = Mock(return_value='')
9798
getattr(vm, action)()
9899
if action in ('shutdown_hard', 'poweroff_hard', 'undeploy_hard'):
@@ -108,15 +109,17 @@ def test_states(self):
108109
vm = oca.VirtualMachine('<VM><ID>2</ID><STATE>%s</STATE></VM>' % i,
109110
self.client)
110111
assert vm.str_state == oca.VirtualMachine.VM_STATE[i]
111-
state = oca.VirtualMachine.SHORT_VM_STATES[oca.VirtualMachine.VM_STATE[i]]
112+
state = oca.VirtualMachine.SHORT_VM_STATES[
113+
oca.VirtualMachine.VM_STATE[i]]
112114
assert vm.short_state == state
113115

114116
def test_lcm_states(self):
115117
for i in range(len(oca.VirtualMachine.LCM_STATE)):
116118
xml = '<VM><ID>2</ID><LCM_STATE>%s</LCM_STATE></VM>' % i
117119
vm = oca.VirtualMachine(xml, self.client)
118120
assert vm.str_lcm_state == oca.VirtualMachine.LCM_STATE[i]
119-
lcm = oca.VirtualMachine.SHORT_LCM_STATES[oca.VirtualMachine.LCM_STATE[i]]
121+
lcm = oca.VirtualMachine.SHORT_LCM_STATES[
122+
oca.VirtualMachine.LCM_STATE[i]]
120123
assert vm.short_lcm_state == lcm
121124

122125
def test_resubmit(self):

0 commit comments

Comments
 (0)