1
0
mirror of https://github.com/quay/quay.git synced 2026-01-27 18:42:52 +03:00
Files
quay/data/test/test_text.py
Kenny Lee Sin Cheong 5f63b3a7bb chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -04:00

38 lines
987 B
Python

from test.fixtures import *
import pytest
from data.database import Repository
from data.text import match_like, match_mysql
@pytest.mark.parametrize(
"input",
[
("hello world"),
("hello ' world"),
('hello " world'),
("hello ` world"),
],
)
def test_mysql_text_escaping(input):
query, values = Repository.select().where(match_mysql(Repository.description, input)).sql()
assert input not in query
@pytest.mark.parametrize(
"input, expected",
[
("hello world", "hello world"),
("hello 'world", "hello world"),
('hello "world', "hello world"),
("hello `world", "hello world"),
("hello !world", "hello !!world"),
("hello %world", "hello !%world"),
],
)
def test_postgres_text_escaping(input, expected):
query, values = Repository.select().where(match_like(Repository.description, input)).sql()
assert input not in query
assert values[0] == "%" + expected + "%"