From b9503546dfa1f73f9028161464298bc264f07390 Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Mon, 13 Sep 2021 02:32:40 -0700 Subject: [PATCH] Move structured samples and remove old tests --- .../parsing => .samples}/arista_route.json | 0 .../frr_bgp_community.json | 0 .../parsing => .samples}/frr_bgp_route.json | 0 .../juniper_route_aspath.xml | 0 .../juniper_route_direct.xml | 0 .../juniper_route_indirect.xml | 0 hyperglass/parsing/test_arista.py | 25 ------------ hyperglass/parsing/test_juniper.py | 39 ------------------- 8 files changed, 64 deletions(-) rename {hyperglass/models/parsing => .samples}/arista_route.json (100%) rename {hyperglass/models/parsing => .samples}/frr_bgp_community.json (100%) rename {hyperglass/models/parsing => .samples}/frr_bgp_route.json (100%) rename {hyperglass/models/parsing => .samples}/juniper_route_aspath.xml (100%) rename {hyperglass/models/parsing => .samples}/juniper_route_direct.xml (100%) rename {hyperglass/models/parsing => .samples}/juniper_route_indirect.xml (100%) delete mode 100644 hyperglass/parsing/test_arista.py delete mode 100644 hyperglass/parsing/test_juniper.py diff --git a/hyperglass/models/parsing/arista_route.json b/.samples/arista_route.json similarity index 100% rename from hyperglass/models/parsing/arista_route.json rename to .samples/arista_route.json diff --git a/hyperglass/models/parsing/frr_bgp_community.json b/.samples/frr_bgp_community.json similarity index 100% rename from hyperglass/models/parsing/frr_bgp_community.json rename to .samples/frr_bgp_community.json diff --git a/hyperglass/models/parsing/frr_bgp_route.json b/.samples/frr_bgp_route.json similarity index 100% rename from hyperglass/models/parsing/frr_bgp_route.json rename to .samples/frr_bgp_route.json diff --git a/hyperglass/models/parsing/juniper_route_aspath.xml b/.samples/juniper_route_aspath.xml similarity index 100% rename from hyperglass/models/parsing/juniper_route_aspath.xml rename to .samples/juniper_route_aspath.xml diff --git a/hyperglass/models/parsing/juniper_route_direct.xml b/.samples/juniper_route_direct.xml similarity index 100% rename from hyperglass/models/parsing/juniper_route_direct.xml rename to .samples/juniper_route_direct.xml diff --git a/hyperglass/models/parsing/juniper_route_indirect.xml b/.samples/juniper_route_indirect.xml similarity index 100% rename from hyperglass/models/parsing/juniper_route_indirect.xml rename to .samples/juniper_route_indirect.xml diff --git a/hyperglass/parsing/test_arista.py b/hyperglass/parsing/test_arista.py deleted file mode 100644 index 218fec3..0000000 --- a/hyperglass/parsing/test_arista.py +++ /dev/null @@ -1,25 +0,0 @@ -"""Test Arista JSON Parsing.""" - -# Standard Library -import sys -import json -from pathlib import Path - -# Project -from hyperglass.log import log - -# Local -from .arista import parse_arista - -SAMPLE_FILE = Path(__file__).parent.parent / "models" / "parsing" / "arista_route.json" - -if __name__ == "__main__": - if len(sys.argv) == 2: - sample = sys.argv[1] - else: - with SAMPLE_FILE.open("r") as file: - sample = file.read() - - parsed = parse_arista([sample]) - log.info(json.dumps(parsed, indent=2)) - sys.exit(0) diff --git a/hyperglass/parsing/test_juniper.py b/hyperglass/parsing/test_juniper.py deleted file mode 100644 index 10d2fe9..0000000 --- a/hyperglass/parsing/test_juniper.py +++ /dev/null @@ -1,39 +0,0 @@ -"""Test Juniper XML Parsing.""" - -# Standard Library -import sys -import json -from pathlib import Path - -# Project -from hyperglass.log import log - -# Local -from .juniper import parse_juniper - -SAMPLE_FILES = ( - Path(__file__).parent.parent / "models" / "parsing" / "juniper_route_direct.xml", - Path(__file__).parent.parent / "models" / "parsing" / "juniper_route_indirect.xml", - Path(__file__).parent.parent / "models" / "parsing" / "juniper_route_aspath.xml", -) - - -@log.catch -def run(): - """Run tests.""" - samples = () - if len(sys.argv) == 2: - samples += (sys.argv[1],) - else: - for sample_file in SAMPLE_FILES: - with sample_file.open("r") as file: - samples += (file.read(),) - - for sample in samples: - parsed = parse_juniper([sample]) - log.info(json.dumps(parsed, indent=2)) - sys.exit(0) - - -if __name__ == "__main__": - run()