def test__get_env_enum(self): """Tests if getting correct env enum from string.""" env_options = [ "DEVELOPMENT_ENV", "PERSONAL_ENV", "PRODUCTION_ENV", "STAGING_ENV", "TESTING_ENV", "UNKNOWN_ENV" ] for index, value in enumerate(env_options): self.assertEqual(ProtoGraph._get_env_enum(value), index) self.assertEqual(ProtoGraph._get_env_enum("NON_EXIST"), 5)
def test_generate_system(self): """Tests if system is added.""" env = "TEST_ENV" system_criticality = 5 proto_graph = ProtoGraph() proto_graph.generate_system(5, system_criticality, 5, "system.system5.*", "system 5", env, "system number 5") self.assertTrue(hasattr(proto_graph.graph, "systems")) self.assertTrue(hasattr(proto_graph.graph.systems[-1], "system_id")) self.assertTrue( hasattr(proto_graph.graph.systems[-1], "system_collection_id")) self.assertTrue(hasattr(proto_graph.graph.systems[-1], "system_critic")) self.assertTrue(hasattr(proto_graph.graph.systems[-1], "env")) self.assertTrue( hasattr(proto_graph.graph.systems[-1], "regex_grouping")) self.assertTrue(hasattr(proto_graph.graph.systems[-1], "name")) self.assertTrue(hasattr(proto_graph.graph.systems[-1], "description")) self.assertEqual(len(proto_graph.graph.systems), 1) self.assertEqual(proto_graph.graph.systems[-1].system_id, 5) self.assertEqual(proto_graph.graph.systems[-1].system_collection_id, 5) self.assertEqual( proto_graph.graph.systems[-1].system_critic, proto_graph._get_system_criticality_enum(system_criticality)) self.assertEqual(proto_graph.graph.systems[-1].regex_grouping, "system.system5.*") self.assertEqual(proto_graph.graph.systems[-1].name, "system 5") self.assertEqual(proto_graph.graph.systems[-1].env, proto_graph._get_env_enum(env)) self.assertEqual(proto_graph.graph.systems[-1].description, "system number 5")
def test_generate_dataset(self): """Tests if dataset is added.""" env = "DEVELOPMENT_ENV" proto_graph = ProtoGraph() proto_graph.generate_dataset(5, 5, "dataset.dataset5.*", "dataset 5", "5d", env, "dataset number 5") self.assertTrue(hasattr(proto_graph.graph, "datasets")) self.assertTrue(hasattr(proto_graph.graph.datasets[-1], "dataset_id")) self.assertTrue( hasattr(proto_graph.graph.datasets[-1], "dataset_collection_id")) self.assertTrue( hasattr(proto_graph.graph.datasets[-1], "regex_grouping")) self.assertTrue(hasattr(proto_graph.graph.datasets[-1], "name")) self.assertTrue(hasattr(proto_graph.graph.datasets[-1], "slo")) self.assertTrue(hasattr(proto_graph.graph.datasets[-1], "env")) self.assertTrue(hasattr(proto_graph.graph.datasets[-1], "description")) self.assertEqual(len(proto_graph.graph.datasets), 1) self.assertEqual(proto_graph.graph.datasets[-1].dataset_id, 5) self.assertEqual(proto_graph.graph.datasets[-1].dataset_collection_id, 5) self.assertEqual(proto_graph.graph.datasets[-1].regex_grouping, "dataset.dataset5.*") self.assertEqual(proto_graph.graph.datasets[-1].name, "dataset 5") self.assertEqual(proto_graph.graph.datasets[-1].slo, "5d") self.assertEqual(proto_graph.graph.datasets[-1].env, proto_graph._get_env_enum(env)) self.assertEqual(proto_graph.graph.datasets[-1].description, "dataset number 5")