Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix local test test_get_config_file fail #2705

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions tests/flytekit/unit/configuration/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import mock
import pytest
from pathlib import Path
from pytimeparse.timeparse import timeparse

from flytekit.configuration import ConfigEntry, get_config_file, set_if_exists
from flytekit.configuration.file import LegacyConfigEntry, _exists
from flytekit.configuration.file import LegacyConfigEntry, _exists, FLYTECTL_CONFIG_ENV_VAR, FLYTECTL_CONFIG_ENV_VAR_OVERRIDE
from flytekit.configuration.internal import Platform


Expand Down Expand Up @@ -42,8 +43,23 @@ def test_exists(data, expected):


def test_get_config_file():
def all_path_not_exists(paths):
for path in paths:
if path.exists():
return False
return True

paths = [
Path("flytekit.config"),
Path(Path.home(), ".flyte", "config"),
Path(Path.home(), ".flyte", "config.yaml")
]
config_file = os.getenv(FLYTECTL_CONFIG_ENV_VAR_OVERRIDE, os.getenv(FLYTECTL_CONFIG_ENV_VAR))
if config_file:
paths.append(Path(config_file))

c = get_config_file(None)
assert c is None
assert (c is None) == all_path_not_exists(paths)
c = get_config_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config"))
assert c is not None
assert c.legacy_config is not None
Expand Down
Loading