23 lines
759 B
Python
23 lines
759 B
Python
from unittest.mock import AsyncMock
|
|
|
|
import pytest
|
|
|
|
from app.db.bgp_prefix_geo import (
|
|
BGP_PREFIX_GEO_FUNCTION_SQL,
|
|
BGP_PREFIX_GEO_INDEX_SQL,
|
|
install_bgp_prefix_geo_functions,
|
|
)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fresh_database_installs_lookup_functions_without_large_index():
|
|
connection = AsyncMock()
|
|
|
|
await install_bgp_prefix_geo_functions(connection)
|
|
|
|
statements = [str(call.args[0]) for call in connection.execute.call_args_list]
|
|
assert len(statements) == len(BGP_PREFIX_GEO_FUNCTION_SQL) == 2
|
|
assert all("CREATE OR REPLACE FUNCTION" in statement for statement in statements)
|
|
assert all("CREATE INDEX" not in statement for statement in statements)
|
|
assert "CREATE INDEX CONCURRENTLY" in BGP_PREFIX_GEO_INDEX_SQL
|