Skip to content

Commit 113022d

Browse files
committed
Add first integration tests
1 parent ac18385 commit 113022d

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# vim: set fileencoding=utf8
2+
# encoding:utf8
3+
#
4+
# Author: Matthias Schmitz <[email protected]>
5+
6+
import unittest
7+
import os
8+
import oca
9+
10+
11+
@unittest.skipUnless(os.environ.has_key('OCA_INT_TESTS'),
12+
"Skipping integration tests")
13+
class IntTestClient(unittest.TestCase):
14+
def setUp(self):
15+
try:
16+
del os.environ["ONE_AUTH"]
17+
except KeyError:
18+
pass
19+
20+
self.c = oca.Client(os.environ['OCA_INT_TESTS_ONE_AUTH'],
21+
os.environ['OCA_INT_TESTS_ONE_XMLRPC'])
22+
23+
def test_connection(self):
24+
self.assertIn(os.environ['OCA_INT_TESTS'], self.c.version())
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# vim: set fileencoding=utf8
2+
# encoding:utf8
3+
#
4+
# Author: Matthias Schmitz <[email protected]>
5+
6+
import unittest
7+
import os
8+
import oca
9+
from oca.exceptions import OpenNebulaException
10+
11+
@unittest.skipUnless(os.environ.has_key('OCA_INT_TESTS'),
12+
"Skipping integration tests")
13+
class IntTestTemplate(unittest.TestCase):
14+
def setUp(self):
15+
try:
16+
del os.environ["ONE_AUTH"]
17+
except KeyError:
18+
pass
19+
20+
self.c = oca.Client(os.environ['OCA_INT_TESTS_ONE_AUTH'], os.environ['OCA_INT_TESTS_ONE_XMLRPC'])
21+
22+
def tearDown(self):
23+
print "teardown"
24+
vmp = oca.VirtualMachinePool(self.c)
25+
vmp.info()
26+
27+
def test_allocate(self):
28+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest01</NAME><TEMPLATE/></VMTEMPLATE>')
29+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest02</NAME><TEMPLATE/></VMTEMPLATE>')
30+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest03</NAME><TEMPLATE/></VMTEMPLATE>')
31+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest04</NAME><TEMPLATE/></VMTEMPLATE>')
32+
33+
def test_allocate_with_same_name(self):
34+
with self.assertRaises(OpenNebulaException):
35+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest01</NAME><TEMPLATE/></VMTEMPLATE>')
36+
37+
38+
def test_update(self):
39+
oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest_update01</NAME><TEMPLATE/></VMTEMPLATE>')
40+
tp = oca.VmTemplatePool(self.c)
41+
tp.info()
42+
templ = tp.get_by_name('inttest_update01')
43+
templ.update('MEMORY=1024 CPU=2')
44+
45+
def test_delete(self):
46+
tp = oca.VmTemplatePool(self.c)
47+
tp.info()
48+
for tpl in tp:
49+
if tpl.name.startswith('inttest'):
50+
tpl.delete()
51+
52+
def test_instantiate(self):
53+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest_instantiate_me01</NAME><MEMORY>1234</MEMORY><CPU>2</CPU></VMTEMPLATE>')
54+
tp = oca.VmTemplatePool(self.c)
55+
tp.info()
56+
templ = tp.get_by_name('inttest_instantiate_me01')
57+
templ.instantiate()
58+

0 commit comments

Comments
 (0)