コード例 #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)
コード例 #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
コード例 #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
コード例 #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"