def test_success(self): config = outdent(""" <cluster> <clusternodes> <clusternode name="node1" nodeid="1"> <altname name="node1-altname"/> </clusternode> <clusternode name="node2" nodeid="2"/> <clusternode name="node3" nodeid="3"/> </clusternodes> </cluster> """) self.assert_equal_nodelist([{ "ring0": "node1", "ring1": "node1-altname", "name": None, "id": "1", }, { "ring0": "node2", "ring1": None, "name": None, "id": "2", }, { "ring0": "node3", "ring1": None, "name": None, "id": "3", }], lib.ClusterConfFacade( etree.XML(config)).get_nodes())
def test_missing_info(self): config = outdent(""" <cluster> <clusternodes> <clusternode nodeid="1"/> <clusternode name="node2"> <altname/> </clusternode> <clusternode/> </clusternodes> </cluster> """) self.assert_equal_nodelist([{ "ring0": None, "ring1": None, "name": None, "id": "1", }, { "ring0": "node2", "ring1": None, "name": None, "id": None, }, { "ring0": None, "ring1": None, "name": None, "id": None, }], lib.ClusterConfFacade( etree.XML(config)).get_nodes())
def test_no_nodes(self): config = "<cluster/>" self.assert_equal_nodelist([], lib.ClusterConfFacade( etree.XML(config)).get_nodes())
def test_not_cluster_element(self): cfg = etree.XML('<not_cluster/>') self.assertEqual("", lib.ClusterConfFacade(cfg).get_cluster_name())
def test_success(self): cfg = etree.XML('<cluster name="cluster-name"/>') self.assertEqual("cluster-name", lib.ClusterConfFacade(cfg).get_cluster_name())