Пример #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')