def test_gen_namespaces_without_namespace(self): """Test that gen_namespaces arranges the output dict in the expected way. If no namespaces are specified, namespaces are generated. """ in_nodes = self.attributes.get("nodes") generator = OCPGenerator(self.two_hours_ago, self.now) out_namespaces = generator._gen_namespaces(in_nodes[0]) # auto-generating namespaces should create at least 2 namespaces self.assertGreaterEqual(len(out_namespaces), 1)
def test_gen_namespaces_with_namespace(self): """Test that gen_namespaces arranges the output dict in the expected way. If namespaces are specified, namespaces are not generated. """ in_nodes = self.attributes.get("nodes") generator = OCPGenerator(self.two_hours_ago, self.now, self.attributes) out_namespaces = generator._gen_namespaces(in_nodes) self.assertEqual(list(out_namespaces.keys()), list(in_nodes[0].get("namespaces").keys())) for value in out_namespaces.values(): with self.subTest(node=value): self.assertEqual(list(value.get("namespaces").keys()), list(in_nodes[0].get("namespaces").keys()))
def test_gen_namespaces_without_namespace(self): """Test that gen_namespaces arranges the output dict in the expected way. If no namespaces are specified, namespaces are generated. """ in_nodes = self.attributes.get("nodes") del in_nodes[0]["namespaces"] generator = OCPGenerator(self.two_hours_ago, self.now, self.attributes) out_namespaces = generator._gen_namespaces(in_nodes) # auto-generating namespaces should create at least 2 namespaces self.assertGreater(len(list(out_namespaces.keys())), 1) for value in out_namespaces.values(): with self.subTest(namespace=value): self.assertEqual(list(value.keys()), list(in_nodes[0].keys()))