Sort env_file.py's imports and test env_files
This commit is contained in:
@@ -9,7 +9,7 @@ import unittest.mock
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from failure import Failure
|
||||
from project_config.settings import held, load, OUTSIDE, ProjectConfig, SETTINGS
|
||||
from project_config.settings import env_files, held, load, OUTSIDE, ProjectConfig, SETTINGS
|
||||
from test_env import isolated_env
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-config"
|
||||
@@ -238,6 +238,15 @@ class HeldTest(ConfigCase):
|
||||
self.assertIsInstance(held(target, self.home), ProjectConfig, "git names the folder by its resolved path")
|
||||
|
||||
|
||||
class EnvFilesTest(ConfigCase):
|
||||
def test_lists_each_readable_configs_env_file_even_one_load_refuses(self) -> None:
|
||||
self.write("acme", CLIENT + 'env-file = "~/acme.env"\n')
|
||||
self.write("misplaced", 'checkout = "~/code/other"\nenv-file = "/srv/other.env"\n')
|
||||
self.write("broken", "checkout = ")
|
||||
self.write("none", CLIENT)
|
||||
self.assertEqual(env_files(self.home), [self.home / "acme.env", pathlib.Path("/srv/other.env")])
|
||||
|
||||
|
||||
class ToolTest(ConfigCase):
|
||||
def run_tool(self, *args: str, cwd: pathlib.Path | None = None) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], cwd=cwd or self.checkout, env={**isolated_env(), "HOME": str(self.home)}, capture_output=True, text=True)
|
||||
|
||||
@@ -7,12 +7,12 @@ import os
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
from failure import Failure
|
||||
from rule_hook.call import Call, text
|
||||
from rule_hook.git import guarded_git
|
||||
from rule_hook.rules import Breach
|
||||
from command_lines.shell_command import resolved, simple_commands
|
||||
from rule_hook.call import Call, text
|
||||
from project_config.settings import env_files
|
||||
from failure import Failure
|
||||
from rule_hook.git import guarded_git
|
||||
from command_lines.shell_command import resolved, simple_commands
|
||||
|
||||
|
||||
def env_file_breaches(call: Call, home: str) -> list[Breach]:
|
||||
|
||||
Reference in New Issue
Block a user