Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_model_with_all_fields():
path = Path(__file__).parent / "resources" / "model_with_all_fields.model.lkml"
with path.open() as file:
raw = file.read()
parsed = lkml.load(raw)
assert parsed is not None
lookml = lkml.dump(parsed)
assert lookml.replace("\n\n", "\n") == raw.replace("\n\n", "\n")
def test_file(path: Path):
with path.open("r") as file:
text = file.read()
try:
parsed = lkml.load(text)
except Exception:
shutil.copy(path, github_path / "load_errors" / path.name)
logging.exception(f"Error parsing {path}")
try:
dumped = lkml.dump(parsed)
lkml.load(dumped)
except Exception:
with open(github_path / "dump_errors" / path.name, "w+") as file:
file.write(dumped)
logging.exception(f"Error serializing {path}")
def test_view_with_all_fields():
path = Path(__file__).parent / "resources" / "view_with_all_fields.view.lkml"
with path.open() as file:
raw = file.read()
parsed = lkml.load(raw)
assert parsed is not None
lookml = lkml.dump(parsed)
assert lookml.replace("\n\n", "\n") == raw.replace("\n\n", "\n")