def test_required_fields_missing(self): body = {'not a node name': 'wibble'} data = nodes.NodeData(body) self.assertRaises(exc.HTTPBadRequest, data.name) self.assertRaises(exc.HTTPBadRequest, data.profile_id) self.assertIsNone(data.cluster_id()) self.assertIsNone(data.role()) self.assertIsNone(data.metadata())
def test_with_profile_id(self): body = {'profile_id': 'my-stack', 'name': 'test_node'} data = nodes.NodeData(body) self.assertEqual('test_node', data.name()) self.assertEqual('my-stack', data.profile_id())
def test_with_cluster_id(self): body = {'cluster_id': 'cluster-1', 'name': 'test_node'} data = nodes.NodeData(body) self.assertEqual('test_node', data.name()) self.assertEqual('cluster-1', data.cluster_id())
def test_node_name(self): body = {'name': 'test_node'} data = nodes.NodeData(body) self.assertEqual('test_node', data.name())