Add additional asserts.
@@ -93,15 +93,27 @@ class SoftLayerTests(unittest.TestCase):
self.assertEqual(node.state, NODE_STATE_MAP['RUNNING'])
def test_create_node_ex_hourly_True(self):
- SoftLayerMockHttp.type = 'HOURLY_BILLING'
+ SoftLayerMockHttp.type = 'HOURLY_BILLING_TRUE'
node = self.driver.create_node(name="libcloud-testing",
location=self.driver.list_locations()[0],
size=self.driver.list_sizes()[0],
- image=self.driver.list_images()[0])
+ image=self.driver.list_images()[0],
+ ex_hourly=True)
+ self.assertEqual(node.name, 'libcloud-testing.example.com')
+ self.assertEqual(node.state, NODE_STATE_MAP['RUNNING'])
+
+ SoftLayerMockHttp.type = 'HOURLY_BILLING_FALSE'
+
+ node = self.driver.create_node(name="libcloud-testing",
+ location=self.driver.list_locations()[0],
+ size=self.driver.list_sizes()[0],
+ image=self.driver.list_images()[0],
+ ex_hourly=False)
self.assertEqual(node.name, 'libcloud-testing.example.com')
self.assertEqual(node.state, NODE_STATE_MAP['RUNNING'])
+
def test_create_fail(self):
SoftLayerMockHttp.type = "SOFTLAYEREXCEPTION"
self.assertRaises(
@@ -223,10 +235,11 @@ class SoftLayerMockHttp(MockHttp, unittest.TestCase):
None: 'v3__SoftLayer_Virtual_Guest_createObject.xml',
'INVALIDCREDSERROR': 'SoftLayer_Account.xml',
'SOFTLAYEREXCEPTION': 'fail.xml',
- 'HOURLY_BILLING': 'v3__SoftLayer_Virtual_Guest_createObject.xml',
+ 'HOURLY_BILLING_TRUE': 'v3__SoftLayer_Virtual_Guest_createObject.xml',
+ 'HOURLY_BILLING_FALSE': 'v3__SoftLayer_Virtual_Guest_createObject.xml',
}[self.type]
- if self.type == 'HOURLY_BILLING':
+ if self.type == 'HOURLY_BILLING_TRUE':
# Verify parameter is sent as a boolean and not as a string
expected_value = """
<member>
@@ -236,6 +249,17 @@ class SoftLayerMockHttp(MockHttp, unittest.TestCase):
""".strip()
self.assertTrue(expected_value in body, 'Request body is missing hourlyBillingFlag attribute')
+ elif self.type == 'HOURLY_BILLING_FALSE':
+ # Verify parameter is sent as a boolean and not as a string
+ expected_value = """
+<member>
+<name>hourlyBillingFlag</name>
+<value><boolean>0</boolean></value>
+</member>
+""".strip()
+
+ self.assertTrue(expected_value in body, 'Request body is missing hourlyBillingFlag attribute')
+
body = self.fixtures.load(fixture)
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
