Beispiel #1
0
def test_mandatory_value_not_set_valid2(init_env, monkeypatch):
    instance = CheckEnv(
        env_filename=os.path.join(dir_path, 'fixtures/valid2.json'))
    instance.load_spec_file()
    instance.apply_spec()
    assert ['VALUE1_NOT_SET'] == instance.missing
    assert set(['VALUE3_NOT_SET_NOT_REQUIRED',
                'VALUE2_NOT_SET_WITH_DEFAULT']) == set(instance.optional)
Beispiel #2
0
def test_all_env_names_set_valid1(init_env, monkeypatch):
    monkeypatch.setenv("VALUE1", "value1")
    monkeypatch.setenv("VALUE2", "value2")
    monkeypatch.setenv("VALUE3", "value3")
    monkeypatch.setenv("VALUE4", "value4")
    monkeypatch.setenv("VALUE5", "value5")

    instance = CheckEnv(
        env_filename=os.path.join(dir_path, 'fixtures/valid1.json'))
    instance.load_spec_file()
    instance.apply_spec()

    # nothing should be in mandatory or optional sets
    assert [] == instance.missing
    assert [] == instance.optional
    assert instance.check_failed == False
Beispiel #3
0
def test_ensure_check_failed(init_env):
    instance = CheckEnv(
        env_filename=os.path.join(dir_path, 'fixtures/valid2.json'))
    instance.load_spec_file()
    instance.apply_spec()
    assert instance.check_failed == True
Beispiel #4
0
def test_default_mandatory_value_set(init_env):
    instance = CheckEnv(
        env_filename=os.path.join(dir_path, 'fixtures/valid2.json'))
    instance.load_spec_file()
    instance.apply_spec()
    assert os.getenv("VALUE2_NOT_SET_WITH_DEFAULT") == "3000"
Beispiel #5
0
def test_valid_config_loads():
    instance = CheckEnv(
        env_filename=os.path.join(dir_path, 'fixtures/valid1.json'))
    instance.load_spec_file()
Beispiel #6
0
def test_invalid_config(init_env):
    with pytest.raises(ValidationError):
        instance = CheckEnv(
            env_filename=os.path.join(dir_path, 'fixtures/invalid.json'))
        instance.load_spec_file()
Beispiel #7
0
def test_no_config_file(init_env):
    with pytest.raises(IOError):
        instance = CheckEnv()
        instance.load_spec_file()