def test_init_app_on_create(app):
    gsa = GoogleServiceAccount('TEST', app)

    assert 'gsa' in app.extensions

    with app.app_context():
        assert gsa._get_state() is not None
def test_get_state_unregistered_app():
    """Verify that error is raised when extension is used without registering
    an app with init_app."""
    gsa = GoogleServiceAccount('TEST')
    app = Flask(__name__)

    with pytest.raises(AssertionError):
        with app.app_context():
            gsa._get_state()
def test_multiple_extensions(app):
    app.config.update({
        'TEST2_PK_FILE': 'tests/data/test.p12',
        'TEST2_PK_PASSWORD': '******',
        'TEST2_EMAIL': '*****@*****.**',
    })
    gsa1 = GoogleServiceAccount('TEST')
    gsa2 = GoogleServiceAccount('TEST2')

    gsa1.init_app(app)
    gsa2.init_app(app)

    assert len(app.extensions['gsa']) == 2
def test_multiple_apps():
    app1 = make_app()
    app2 = make_app()
    gsa = GoogleServiceAccount('TEST')
    gsa.init_app(app1)
    gsa.init_app(app2)