Example #1
0
class TestHasAny(unittest.TestCase):
    @parameterized.expand([
        (
            'hasAny("mental_abilities","physical_abilities")',
            HasAny(Field('mental_abilities'), Field('physical_abilities')),
        ),
        ('hasAny([1, 2, 3, 4],[3])', HasAny(Array([1, 2, 3, 4]), Array([3]))),
        ("hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])",
         HasAny(
             Field('bands'),
             Array(['port-royal', 'hammock'], ToFixedString, {'length': 20}))),
    ])
    def test_get_sql(self, expected: str, func: HasAny):
        self.assertEqual(expected, func.get_sql())
Example #2
0
class TestNotEmpty(unittest.TestCase):
    @parameterized.expand([
        (
            'notEmpty("tags")',
            NotEmpty(Field("tags")),
        ),
        ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))),
    ])
    def test_get_sql(self, expected: str, func: NotEmpty):
        self.assertEqual(expected, func.get_sql())
Example #3
0
class TestLength(unittest.TestCase):
    @parameterized.expand([
        (
            'length("tags")',
            Length(Field("tags")),
        ),
        ("length([1, 2, 3])", Length(Array([1, 2, 3]))),
    ])
    def test_get_sql(self, expected: str, func: Length):
        self.assertEqual(expected, func.get_sql())
Example #4
0
class TestArray(unittest.TestCase):
    @parameterized.expand([
        (
            "['ridley', 'scott', 'jimi', 'hendrix']",
            Array(["ridley", "scott", "jimi", "hendrix"]),
        ),
        (
            "[1, 2, 3, 4]",
            Array([1, 2, 3, 4]),
        ),
        (
            "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]",
            Array(["1", "2", "3", "4"], ToInt64),
        ),
        (
            "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)]",
            Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}),
        ),
    ])
    def test_get_sql(self, expected: str, array: Array):
        self.assertEqual(expected, array.get_sql())
Example #5
0
class TestArray(unittest.TestCase):
    @parameterized.expand([
        (
            "['ridley', 'scott', 'jimi', 'hendrix']",
            Array(['ridley', 'scott', 'jimi', 'hendrix']),
        ),
        (
            "[1, 2, 3, 4]",
            Array([1, 2, 3, 4]),
        ),
        (
            "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]",
            Array(['1', '2', '3', '4'], ToInt64),
        ),
        (
            "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)]",
            Array(['mogwai', 'mono', 'bonobo'], ToFixedString, {'length': 10}),
        ),
    ])
    def test_get_sql(self, expected: str, array: Array):
        self.assertEqual(expected, array.get_sql())
Example #6
0
 def test_get_sql(self, expected: str, array: Array):
     self.assertEqual(expected, array.get_sql())