Skip to content

Commit 7d61739

Browse files
committed
Update tests for new functionality / OpenNebula 4.10
1 parent 63c2965 commit 7d61739

7 files changed

Lines changed: 30 additions & 7 deletions

File tree

oca/tests/fixtures/host.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
<USED_CPU>0</USED_CPU>
2323
<RUNNING_VMS>3</RUNNING_VMS>
2424
</HOST_SHARE>
25+
<VMS>
26+
<ID>82</ID>
27+
<ID>84</ID>
28+
<ID>85</ID>
29+
<ID>95</ID>
30+
<ID>96</ID>
31+
</VMS>
2532
<TEMPLATE>
2633
<CPUSPEED>2.2GHz</CPUSPEED>
2734
<FREECPU>800</FREECPU>

oca/tests/fixtures/hostpool.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<USED_CPU>0</USED_CPU>
2525
<RUNNING_VMS>3</RUNNING_VMS>
2626
</HOST_SHARE>
27+
<VMS/>
2728
<TEMPLATE></TEMPLATE>
2829
</HOST>
2930
<HOST>
@@ -51,6 +52,7 @@
5152
<USED_CPU>0</USED_CPU>
5253
<RUNNING_VMS>0</RUNNING_VMS>
5354
</HOST_SHARE>
55+
<VMS/>
5456
<TEMPLATE></TEMPLATE>
5557
</HOST>
5658
</HOST_POOL>

oca/tests/fixtures/vm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<REQUIREMENTS>MAC="50:20:20:20:20:20"</REQUIREMENTS>
4646
<VMID>6</VMID>
4747
</TEMPLATE>
48+
<USER_TEMPLATE>
49+
<GREETING><![CDATA[Hello World]]></GREETING>
50+
</USER_TEMPLATE>
4851
<HISTORY_RECORDS>
4952
<HISTORY>
5053
<SEQ>0</SEQ>

oca/tests/fixtures/vmpool.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<NET_TX>12345</NET_TX>
1919
<NET_RX>0</NET_RX>
2020
<TEMPLATE></TEMPLATE>
21+
<USER_TEMPLATE/>
2122
<HISTORY_RECORDS>
2223
<HISTORY>
2324
<SEQ>0</SEQ>
@@ -54,6 +55,7 @@
5455
<NET_TX>12345</NET_TX>
5556
<NET_RX>0</NET_RX>
5657
<TEMPLATE></TEMPLATE>
58+
<USER_TEMPLATE/>
5759
<HISTORY_RECORDS>
5860
<HISTORY>
5961
<SEQ>0</SEQ>
@@ -90,6 +92,7 @@
9092
<NET_TX>12345</NET_TX>
9193
<NET_RX>0</NET_RX>
9294
<TEMPLATE></TEMPLATE>
95+
<USER_TEMPLATE/>
9396
<HISTORY_RECORDS>
9497
<HISTORY>
9598
<SEQ>0</SEQ>

oca/tests/test_client.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ def setUp(self):
1717

1818
def test_secret(self):
1919
c = oca.Client('test:test')
20-
assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
20+
assert c.one_auth == 'test:test'
2121

2222
def test_one_auth(self):
2323
os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__),
2424
'tests/fixtures/one_auth')
2525
try:
2626
c = oca.Client()
27-
secret = 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
27+
secret = 'test:test'
2828
assert c.one_auth == secret
2929
finally:
3030
os.environ["ONE_AUTH"] = ''
@@ -33,7 +33,7 @@ def test_default_user_path(self):
3333
os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__),
3434
'tests/fixtures/one_auth')
3535
c = oca.Client()
36-
assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
36+
assert c.one_auth == 'test:test'
3737

3838
@raises(oca.OpenNebulaException)
3939
def test_wrong_default_user_path(self):
@@ -46,10 +46,6 @@ def test_invalid_secret(self):
4646
'tests/fixtures/one_auth')
4747
c = oca.Client('testtest')
4848

49-
def test_with_plain(self):
50-
c = oca.Client('test:plain:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3')
51-
assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
52-
5349
def test_addres(self):
5450
c = oca.Client('test:test', "http://8.8.8.8:2633/RPC2")
5551
assert c.one_address == "http://8.8.8.8:2633/RPC2"

oca/tests/test_host.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ def test_host_share_repr(self):
4646
h._convert_types()
4747
share = h.host_share
4848
assert repr(share) == '<oca.vm.HostShare()>'
49+
50+
def test_host_vm_ids(self):
51+
h = oca.Host(self.xml, self.client)
52+
h._convert_types()
53+
vm_ids = h.vm_ids
54+
assert vm_ids == [82,84,85,95,96]

oca/tests/test_virtualmachine.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,9 @@ def test_no_history_records_element(self):
144144
vm.xml.remove(vm.xml.find('HISTORY_RECORDS'))
145145
vm._convert_types()
146146
assert vm.history_records == []
147+
148+
def test_user_template_variables(self):
149+
vm = oca.VirtualMachine(self.xml, self.client)
150+
vm._convert_types()
151+
greeting = vm.user_template.greeting
152+
assert greeting == "Hello World"

0 commit comments

Comments
 (0)