Repository: softlayer/softlayer-python
Pull request #879 (2017-09-28 17:20:41)

resource metadata update 
eg: need to call as getDomain, not Domain.


Patch:
diff --git a/SoftLayer/fixtures/SoftLayer_Resource_Metadata.py b/SoftLayer/fixtures/SoftLayer_Resource_Metadata.py
index e0475d9f..2f72a82c 100644
--- a/SoftLayer/fixtures/SoftLayer_Resource_Metadata.py
+++ b/SoftLayer/fixtures/SoftLayer_Resource_Metadata.py
@@ -1,8 +1,8 @@
-FrontendMacAddresses = ['06-00-00-00-00-00']
-BackendMacAddresses = ['07-00-00-00-00-00']
-FrontendMacAddresses = ['06-00-00-00-00-00']
-Router = 'brc01'
-Vlans = [10, 124]
-VlanIds = [8384, 12446]
-Datacenter = 'dal01'
-UserMetadata = 'User-supplied data'
+getFrontendMacAddresses = ['06-00-00-00-00-00']
+getBackendMacAddresses = ['07-00-00-00-00-00']
+getFrontendMacAddresses = ['06-00-00-00-00-00']
+getRouter = 'brc01'
+getVlans = [10, 124]
+getVlanIds = [8384, 12446]
+getDatacenter = 'dal01'
+getUserMetadata = 'User-supplied data'
diff --git a/SoftLayer/managers/metadata.py b/SoftLayer/managers/metadata.py
index 0246d7f7..cdc02151 100644
--- a/SoftLayer/managers/metadata.py
+++ b/SoftLayer/managers/metadata.py
@@ -12,24 +12,24 @@
 
 
 METADATA_MAPPING = {
-    'backend_mac': {'call': 'BackendMacAddresses'},
-    'datacenter': {'call': 'Datacenter'},
-    'datacenter_id': {'call': 'DatacenterId'},
-    'domain': {'call': 'Domain'},
-    'frontend_mac': {'call': 'FrontendMacAddresses'},
-    'fqdn': {'call': 'FullyQualifiedDomainName'},
-    'hostname': {'call': 'Hostname'},
-    'id': {'call': 'Id'},
-    'primary_backend_ip': {'call': 'PrimaryBackendIpAddress'},
-    'primary_ip': {'call': 'PrimaryIpAddress'},
-    'primary_frontend_ip': {'call': 'PrimaryIpAddress'},
-    'provision_state': {'call': 'ProvisionState'},
-    'router': {'call': 'Router', 'param_req': True},
-    'tags': {'call': 'Tags'},
-    'user_data': {'call': 'UserMetadata'},
-    'user_metadata': {'call': 'UserMetadata'},
-    'vlan_ids': {'call': 'VlanIds', 'param_req': True},
-    'vlans': {'call': 'Vlans', 'param_req': True},
+    'backend_mac': {'call': 'getBackendMacAddresses'},
+    'datacenter': {'call': 'getDatacenter'},
+    'datacenter_id': {'call': 'getDatacenterId'},
+    'domain': {'call': 'getDomain'},
+    'frontend_mac': {'call': 'getFrontendMacAddresses'},
+    'fqdn': {'call': 'getFullyQualifiedDomainName'},
+    'hostname': {'call': 'getHostname'},
+    'id': {'call': 'getId'},
+    'primary_backend_ip': {'call': 'getPrimaryBackendIpAddress'},
+    'primary_ip': {'call': 'getPrimaryIpAddress'},
+    'primary_frontend_ip': {'call': 'getPrimaryIpAddress'},
+    'provision_state': {'call': 'getProvisionState'},
+    'router': {'call': 'getRouter', 'param_req': True},
+    'tags': {'call': 'getTags'},
+    'user_data': {'call': 'getUserMetadata'},
+    'user_metadata': {'call': 'getUserMetadata'},
+    'vlan_ids': {'call': 'getVlanIds', 'param_req': True},
+    'vlans': {'call': 'getVlans', 'param_req': True},
 }
 METADATA_ATTRIBUTES = METADATA_MAPPING.keys()
 


Test patch:
diff --git a/tests/managers/metadata_tests.py b/tests/managers/metadata_tests.py
index 1ee2b3bd..c3c288b5 100644
--- a/tests/managers/metadata_tests.py
+++ b/tests/managers/metadata_tests.py
@@ -15,19 +15,19 @@ def set_up(self):
         self.metadata = SoftLayer.MetadataManager(client=self.client)
 
     def test_get(self):
-        mock = self.set_mock('SoftLayer_Resource_Metadata', 'Datacenter')
+        mock = self.set_mock('SoftLayer_Resource_Metadata', 'getDatacenter')
         mock.return_value = 'dal01'
         resp = self.metadata.get('datacenter')
 
         self.assertEqual('dal01', resp)
-        self.assert_called_with('SoftLayer_Resource_Metadata', 'Datacenter',
+        self.assert_called_with('SoftLayer_Resource_Metadata', 'getDatacenter',
                                 identifier=None)
 
     def test_no_param(self):
         resp = self.metadata.get('datacenter')
 
         self.assertEqual('dal01', resp)
-        self.assert_called_with('SoftLayer_Resource_Metadata', 'Datacenter',
+        self.assert_called_with('SoftLayer_Resource_Metadata', 'getDatacenter',
                                 identifier=None,
                                 args=tuple())
 
@@ -35,18 +35,18 @@ def test_w_param(self):
         resp = self.metadata.get('vlans', '1:2:3:4:5')
 
         self.assertEqual([10, 124], resp)
-        self.assert_called_with('SoftLayer_Resource_Metadata', 'Vlans',
+        self.assert_called_with('SoftLayer_Resource_Metadata', 'getVlans',
                                 args=('1:2:3:4:5',))
 
     def test_user_data(self):
         resp = self.metadata.get('user_data')
 
         self.assertEqual(resp, 'User-supplied data')
-        self.assert_called_with('SoftLayer_Resource_Metadata', 'UserMetadata',
+        self.assert_called_with('SoftLayer_Resource_Metadata', 'getUserMetadata',
                                 identifier=None)
 
     def test_return_none(self):
-        mock = self.set_mock('SoftLayer_Resource_Metadata', 'Datacenter')
+        mock = self.set_mock('SoftLayer_Resource_Metadata', 'getDatacenter')
         mock.return_value = None
 
         resp = self.metadata.get('datacenter')
@@ -54,7 +54,7 @@ def test_return_none(self):
         self.assertEqual(None, resp)
 
     def test_404(self):
-        mock = self.set_mock('SoftLayer_Resource_Metadata', 'UserMetadata')
+        mock = self.set_mock('SoftLayer_Resource_Metadata', 'getUserMetadata')
         mock.side_effect = SoftLayer.SoftLayerAPIError(404, 'Not Found')
         resp = self.metadata.get('user_data')
 
@@ -62,7 +62,7 @@ def test_404(self):
 
     def test_error(self):
         exception = SoftLayer.SoftLayerAPIError(500, 'Error')
-        mock = self.set_mock('SoftLayer_Resource_Metadata', 'UserMetadata')
+        mock = self.set_mock('SoftLayer_Resource_Metadata', 'getUserMetadata')
         mock.side_effect = exception
 
         self.assertRaises(SoftLayer.SoftLayerAPIError,