Skip to content

Commit 18f7228

Browse files
committed
Merge pull request python-oca#14 from mattthias/master_inttests
Add integrationtests
2 parents ac18385 + c9ac541 commit 18f7228

3 files changed

Lines changed: 119 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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
for vm in vmp:
27+
if vm.name.startswith('inttest_vm_'):
28+
vm.delete()
29+
30+
def test_allocate(self):
31+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest01</NAME><TEMPLATE/></VMTEMPLATE>')
32+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest02</NAME><TEMPLATE/></VMTEMPLATE>')
33+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest03</NAME><TEMPLATE/></VMTEMPLATE>')
34+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest04</NAME><TEMPLATE/></VMTEMPLATE>')
35+
36+
def test_allocate_with_same_name(self):
37+
with self.assertRaises(OpenNebulaException):
38+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest01</NAME><TEMPLATE/></VMTEMPLATE>')
39+
40+
41+
def test_update(self):
42+
oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest_update01</NAME><TEMPLATE/></VMTEMPLATE>')
43+
tp = oca.VmTemplatePool(self.c)
44+
tp.info()
45+
templ = tp.get_by_name('inttest_update01')
46+
templ.update('MEMORY=1024 CPU=2')
47+
48+
def test_delete(self):
49+
tp = oca.VmTemplatePool(self.c)
50+
tp.info()
51+
for tpl in tp:
52+
if tpl.name.startswith('inttest'):
53+
tpl.delete()
54+
55+
def test_instantiate(self):
56+
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest_instantiate_me01</NAME><MEMORY>1234</MEMORY><CPU>2</CPU></VMTEMPLATE>')
57+
tp = oca.VmTemplatePool(self.c)
58+
tp.info()
59+
templ = tp.get_by_name('inttest_instantiate_me01')
60+
templ.instantiate('inttest_vm_instantiate_me01')
61+
vmpool = oca.VirtualMachinePool(self.c)
62+
vmpool.info()
63+
vm = vmpool.get_by_name('inttest_vm_instantiate_me01')
64+
self.assertEqual(vm.name, 'inttest_vm_instantiate_me01')
65+

tox-integrationtests.ini

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[tox]
2+
envlist = py27-v4.{8,10,12,14}
3+
4+
[testenv]
5+
deps=nose
6+
mock
7+
coverage
8+
commands=nosetests
9+
passenv = OCA_INT_TESTS_ONE_AUTH
10+
11+
[testenv:py27-v4.8]
12+
setenv =
13+
OCA_INT_TESTS=4.8
14+
OCA_INT_TESTS_ONE_XMLRPC=http://192.168.122.204:2633/RPC2
15+
16+
[testenv:py27-v4.10]
17+
setenv =
18+
OCA_INT_TESTS=4.10
19+
OCA_INT_TESTS_ONE_XMLRPC=http://192.168.122.41:2633/RPC2
20+
21+
[testenv:py27-v4.12]
22+
setenv =
23+
OCA_INT_TESTS=4.12
24+
OCA_INT_TESTS_ONE_XMLRPC=http://192.168.122.197:2633/RPC2
25+
26+
[testenv:py27-v4.14]
27+
setenv =
28+
OCA_INT_TESTS=4.13
29+
OCA_INT_TESTS_ONE_XMLRPC=http://192.168.122.10:2633/RPC2
30+

0 commit comments

Comments
 (0)