def test_gen_nodes_without_nodes(self): """Test that gen_nodes arranges the output dict in the expected way. If nodes are not specified, nodes are generated. """ generator = OCPGenerator(self.two_hours_ago, self.now, {}) out_nodes = generator._gen_nodes() self.assertGreaterEqual(len(list(out_nodes)), 2) self.assertLessEqual(len(list(out_nodes)), 6) expected_keys = [ "name", "cpu_cores", "memory_bytes", "resource_id", "node_labels" ] self.assertEqual(list(out_nodes[0].keys()), expected_keys)
def test_gen_nodes_with_nodes(self): """Test that gen_nodes arranges the output dict in the expected way. If nodes are specified, nodes are not generated. """ in_nodes = self.attributes.get("nodes") generator = OCPGenerator(self.two_hours_ago, self.now, self.attributes) out_nodes = generator._gen_nodes() self.assertEqual(len(list(out_nodes)), len(list(in_nodes))) expected_keys = [ "name", "cpu_cores", "memory_bytes", "resource_id", "namespaces", "node_labels" ] self.assertEqual(list(out_nodes[0].keys()), expected_keys)