示例#1
0
def test_environment_vars():
    os.environ['PASSOUT_SVC'] = 'testservice'
    os.environ['PASSOUT_ENV'] = 'production'
    os.environ['PASSOUT_PATH'] = 'passout/test'
    po = passout.PassOut()
    verify_prod_service1(po)
    reset_env()
示例#2
0
def test_switch_service_and_env():
    po = passout.PassOut('testservice', 'production', 'passout/test')
    verify_prod_service1(po)

    po.svc = 'testservice2'
    po.env = 'development'
    verify_dev_service2(po)
示例#3
0
def test_service_dump():
    po = passout.PassOut('testservice', 'production', 'passout/test')
    svc_dict = po.dumpsvc()

    assert type(svc_dict) == dict
    assert svc_dict['username'] == 'prod_user'
    assert svc_dict['password'] == "%0987654321"
    assert svc_dict['url'] == 'https://prod.myservice.com'
示例#4
0
def test_environment_vars_default_service_env():
    os.environ['PASSOUT_SVC'] = 'testservice'
    os.environ['PASSOUT_PATH'] = 'passout/test'
    po = passout.PassOut()
    verify_dev_service1(po)
    reset_env()
示例#5
0
def test_switch_service():
    po = passout.PassOut('testservice', 'production', 'passout/test')
    verify_prod_service1(po)

    po.svc = 'testservice2'
    verify_prod_service2(po)
示例#6
0
def test_get_env():
    po = passout.PassOut('testservice', 'production', 'passout/test')
    assert po.env == 'production'
示例#7
0
def test_simple_load():
    po = passout.PassOut('testservice', 'production', 'passout/test')
    verify_prod_service1(po)
示例#8
0
def test_write_password_fails():
    po = passout.PassOut('testservice', 'production', 'passout/test')
    with pytest.raises(AttributeError):
        po.password = '******'
示例#9
0
def test_bad_get():
    po = passout.PassOut('testservice', 'production', 'passout/test')
    assert not po.get('nonexistant_key')
示例#10
0
def test_bad_env():
    with pytest.raises(passout.PassOutNoEnvironmentData,
                       match=r"PassOutNoEnvironmentData:.*nonexistant_env"):
        passout.PassOut('testservice', 'nonexistant_env', 'passout/test')
示例#11
0
def test_bad_service():
    with pytest.raises(
            passout.PassOutNoServiceFile,
            match=r"PassOutNoServiceFile:.*nonexistant_service.yml"):
        passout.PassOut('nonexistant_service', 'production', 'passout/test')
示例#12
0
def test_no_service():
    with pytest.raises(passout.PassOutNoService,
                       match=r"PassOutNoService: service not passed*"):
        passout.PassOut()
示例#13
0
def test_bad_path():
    with pytest.raises(passout.PassOutNoServiceFile,
                       match=r"PassOutNoServiceFile:.*doesnotexist.*"):
        passout.PassOut('testservice', 'production', 'doesnotexist')