forked from python-oca/python-oca
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cluster.py
More file actions
33 lines (26 loc) · 1 KB
/
test_cluster.py
File metadata and controls
33 lines (26 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: UTF-8 -*-
import os
import unittest
from mock import Mock
import oca
class TestCluster(unittest.TestCase):
def setUp(self):
self.client = oca.Client('test:test')
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
'tests/fixtures/cluster.xml')).read()
def test_allocate(self):
self.client.call = Mock(return_value=3)
assert oca.Cluster.allocate(self.client, 'test') == 3
def test_repr(self):
self.client.call = Mock()
cluster = oca.Cluster(self.xml, self.client)
assert repr(cluster) == '<oca.Cluster("oneCluster")>'
def test_convert_types(self):
cluster = oca.Cluster(self.xml, None)
cluster._convert_types()
assert cluster.id == 101
assert cluster.name == "oneCluster"
assert cluster.host_ids == [2, 3]
assert cluster.datastore_ids == [4, 5]
assert cluster.vnet_ids == [6, 7]
assert cluster.template.reserved_cpu is None