def test__get_processing_impact_enum(self): """Tests if getting correct processing impact enum from string.""" impact_options = [ "DOWN", "SEVERELY_DEGRADED", "DEGRADED", "OPPORTUNITY_LOSS", "NONE" ] for index, value in enumerate(impact_options): self.assertEqual(ProtoGraph._get_processing_impact_enum(value), index) self.assertEqual(ProtoGraph._get_processing_impact_enum("NON_EXIST"), 4)
def test_generate_processing(self): """Tests if dataset processing is added.""" impact = "TEST_ENV" freshness = "TEST_FRESH" proto_graph = ProtoGraph() proto_graph.generate_processing(5, 5, 5, impact, freshness) self.assertTrue(hasattr(proto_graph.graph, "processings")) self.assertTrue(hasattr(proto_graph.graph.processings[-1], "system_id")) self.assertTrue( hasattr(proto_graph.graph.processings[-1], "dataset_id")) self.assertTrue( hasattr(proto_graph.graph.processings[-1], "processing_id")) self.assertTrue(hasattr(proto_graph.graph.processings[-1], "impact")) self.assertTrue(hasattr(proto_graph.graph.processings[-1], "freshness")) self.assertEqual(len(proto_graph.graph.processings), 1) self.assertEqual(proto_graph.graph.processings[-1].system_id, 5) self.assertEqual(proto_graph.graph.processings[-1].dataset_id, 5) self.assertEqual(proto_graph.graph.processings[-1].processing_id, 5) self.assertEqual(proto_graph.graph.processings[-1].impact, proto_graph._get_processing_impact_enum(impact)) self.assertEqual(proto_graph.graph.processings[-1].freshness, proto_graph._get_processing_freshness_enum(freshness))