Skip to content

Commit 8f45a99

Browse files
committed
fixed broken tests
1 parent a285248 commit 8f45a99

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

functions-python/tasks_executor/tests/tasks/populate_licenses_and_rules/test_populate_licenses.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22
from unittest.mock import MagicMock, patch
33

44
import requests
5+
from sqlalchemy.dialects.postgresql import JSONB
6+
from sqlalchemy.ext.compiler import compiles
57
from shared.database.database import Session
68
from shared.database_gen.sqlacodegen_models import License, Rule
79
from tasks.licenses.populate_licenses import populate_licenses_task
810

11+
12+
# This compilation rule is necessary to make the JSONB type, which is PostgreSQL-specific,
13+
# compatible with the in-memory SQLite database used for testing. It tells SQLAlchemy
14+
# to treat JSONB as JSON when running against a SQLite backend.
15+
@compiles(JSONB, "sqlite")
16+
def compile_jsonb_for_sqlite(element, compiler, **kw):
17+
return compiler.visit_json(element, **kw)
18+
19+
920
# Mock data for GitHub API responses
1021
MOCK_LICENSE_LIST = [
1122
{

0 commit comments

Comments
 (0)