コード例 #1
0
ファイル: test_file.py プロジェクト: flyteorg/flytekit
def test_get_config_file():
    c = get_config_file(None)
    assert c is None
    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

    with pytest.raises(configparser.Error):
        get_config_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/bad.config"))
コード例 #2
0
def test_client_secret_location():
    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/sample.yaml"))
    secret_location = Credentials.CLIENT_CREDENTIALS_SECRET_LOCATION.read(cfg)
    assert secret_location is None

    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/creds_secret_location.yaml"))
    secret_location = Credentials.CLIENT_CREDENTIALS_SECRET_LOCATION.read(cfg)
    assert secret_location == "../tests/flytekit/unit/configuration/configs/fake_secret"
コード例 #3
0
def test_command_2(mocked):
    mocked.environ.get.return_value = "a,b,c"
    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/good.config"))
    res = Credentials.COMMAND.read(cfg)
    assert res == ["a", "b", "c"]
コード例 #4
0
def test_some_int(mocked):
    mocked.environ.get.side_effect = "5"
    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/good.config"))
    res = AWS.RETRIES.read(cfg)
    assert type(res) is int
    assert res == 5
コード例 #5
0
ファイル: test_file.py プロジェクト: flyteorg/flytekit
def test_config_entry_file():
    # Pytest feature
    c = ConfigEntry(LegacyConfigEntry("platform", "url", str))
    assert c.read() is None

    cfg = get_config_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config"))
    assert c.read(cfg) == "fakeflyte.com"

    c = ConfigEntry(LegacyConfigEntry("platform", "url2", str))  # Does not exist
    assert c.read(cfg) is None
コード例 #6
0
ファイル: test_file.py プロジェクト: flyteorg/flytekit
def test_config_entry_precedence():
    # Pytest feature
    c = ConfigEntry(LegacyConfigEntry("platform", "url", str))
    assert c.read() is None

    old_environ = dict(os.environ)
    os.environ["FLYTE_PLATFORM_URL"] = "xyz"
    cfg = get_config_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config"))
    assert c.read(cfg) == "xyz"
    # reset
    os.environ = old_environ
コード例 #7
0
ファイル: test_yaml_file.py プロジェクト: flyteorg/flytekit
def test_config_entry_file():
    c = ConfigEntry(LegacyConfigEntry("platform", "url", str),
                    YamlConfigEntry("admin.endpoint"),
                    lambda x: x.replace("dns:///", ""))
    assert c.read() is None

    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/sample.yaml"))
    assert c.read(cfg) == "flyte.mycorp.io"

    c = ConfigEntry(LegacyConfigEntry("platform", "url2",
                                      str))  # Does not exist
    assert c.read(cfg) is None
コード例 #8
0
ファイル: test_yaml_file.py プロジェクト: flyteorg/flytekit
def test_config_entry_file_2(mock_get):
    # Test reading of the environment variable that flytectl asks users to set.
    # Can take both extensions
    sample_yaml_file_name = os.path.join(
        os.path.dirname(os.path.realpath(__file__)), "configs/sample.yml")

    mock_get.return_value = sample_yaml_file_name

    c = ConfigEntry(LegacyConfigEntry("platform", "url", str),
                    YamlConfigEntry("admin.endpoint"),
                    lambda x: x.replace("dns:///", ""))
    assert c.read() is None

    cfg = get_config_file(sample_yaml_file_name)
    assert c.read(cfg) == "flyte.mycorp.io"

    c = ConfigEntry(LegacyConfigEntry("platform", "url2",
                                      str))  # Does not exist
    assert c.read(cfg) is None
コード例 #9
0
ファイル: test_file.py プロジェクト: flyteorg/flytekit
def test_config_entry_types():
    cfg = get_config_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config"))

    l = ConfigEntry(LegacyConfigEntry("sdk", "workflow_packages", list))
    assert l.read(cfg) == ["this.module", "that.module"]

    s = ConfigEntry(LegacyConfigEntry("madeup", "string_value"))
    assert s.read(cfg) == "abc"

    i = ConfigEntry(LegacyConfigEntry("madeup", "int_value", int))
    assert i.read(cfg) == 3

    b = ConfigEntry(LegacyConfigEntry("madeup", "bool_value", bool))
    assert b.read(cfg) is False

    t = ConfigEntry(
        LegacyConfigEntry("madeup", "timedelta_value", datetime.timedelta),
        transform=lambda x: datetime.timedelta(seconds=timeparse(x)),
    )
    assert t.read(cfg) == datetime.timedelta(hours=20)
コード例 #10
0
ファイル: test_yaml_file.py プロジェクト: flyteorg/flytekit
def test_real_config():
    config_file = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/sample.yaml"))
    res = Platform.INSECURE.read(config_file)
    assert res

    res = Platform.URL.read(config_file)
    assert res == "flyte.mycorp.io"

    res = AWS.S3_ACCESS_KEY_ID.read(config_file)
    assert res == "minio"

    res = AWS.S3_ENDPOINT.read(config_file)
    assert res == "http://localhost:30084"

    res = AWS.S3_SECRET_ACCESS_KEY.read(config_file)
    assert res == "miniostorage"

    res = Credentials.SCOPES.read(config_file)
    assert res == ["all"]
コード例 #11
0
def test_load_images():
    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/images.config"))
    imgs = Images.get_specified_images(cfg)
    assert imgs == {"abc": "docker.io/abc", "xyz": "docker.io/xyz:latest"}
コード例 #12
0
def test_command():
    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/good.config"))
    res = Credentials.COMMAND.read(cfg)
    assert res == ["aws", "sso", "get-token"]
コード例 #13
0
def test_no_images():
    cfg = get_config_file(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "configs/good.config"))
    imgs = Images.get_specified_images(cfg)
    assert imgs == {}