def test_basic():
    name = 'asdfghjkl'
    where = 'https://www.example.com/libraries/extension.zip'

    expected_result = """
        CREATE LIBRARY "{name}"
        LANGUAGE pythonplu
        FROM '{where}'
        WITH CREDENTIALS AS '{creds}'
    """.format(name=name, where=where, creds=CREDS)

    cmd = dialect.CreateLibraryCommand(name,
                                       where,
                                       access_key_id=ACCESS_KEY_ID,
                                       secret_access_key=SECRET_ACCESS_KEY)
    assert clean(expected_result) == clean(compile_query(cmd))
def test_or_replace():
    name = 'SomeLibrary'
    where = 's3://bucket/path/to/archive.zip'

    expected_result = """
        CREATE OR REPLACE LIBRARY "{name}"
        LANGUAGE pythonplu
        FROM '{where}'
        WITH CREDENTIALS AS '{creds}'
    """.format(name=name, where=where, creds=CREDS)

    cmd = dialect.CreateLibraryCommand(name,
                                       where,
                                       access_key_id=ACCESS_KEY_ID,
                                       secret_access_key=SECRET_ACCESS_KEY,
                                       replace=True)
    assert clean(expected_result) == clean(compile_query(cmd))
def test_region():
    name = 'SomeLibrary'
    where = 's3://bucket/path/to/archive.zip'
    region = 'sa-east-1'

    expected_result = """
        CREATE LIBRARY "{name}"
        LANGUAGE pythonplu
        FROM '{where}'
        WITH CREDENTIALS AS '{creds}'
        REGION '{region}'
    """.format(name=name, where=where, creds=CREDS, region=region)

    cmd = dialect.CreateLibraryCommand(name,
                                       where,
                                       access_key_id=ACCESS_KEY_ID,
                                       secret_access_key=SECRET_ACCESS_KEY,
                                       region=region)
    assert clean(expected_result) == clean(compile_query(cmd))