From d40ae799918824a9fe6865ee1d8efda2f5f6744d Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Dec 2023 14:44:40 +0100 Subject: [PATCH] add circular import test --- tests/test_env_resolution.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_env_resolution.py b/tests/test_env_resolution.py index b8086ca..ad6ff60 100644 --- a/tests/test_env_resolution.py +++ b/tests/test_env_resolution.py @@ -1,5 +1,7 @@ from pathlib import Path +import pytest + from src.coordinator import Coordinator from src.env_file_helper import DependencyRule, EnvFile, sort_env_files_by_rule @@ -22,6 +24,20 @@ def test_complex_sorting() -> None: assert sorted_env_files[0].env_type == "e" +def test_circular_import() -> None: + """This test will raise ValueError because the example input cannot be correctly ordered""" + demo_rules = [ + DependencyRule("a", "b"), + DependencyRule("b", "c"), + DependencyRule("c", "a"), + ] + + demo_types = ["a", "b", "c"] + env_files = [EnvFile(env_type=t, env_path=Path(), config=dict()) for t in demo_types] + with pytest.raises(ValueError): + sort_env_files_by_rule(env_files, demo_rules) + + def test_real_env_files() -> None: """authentik should be first"""