Exemple #1
0
    def test_get_query_without_index(self):
        keys = []
        last_values = None
        schema = 'public'
        table = 'test'

        result = get_query(schema, table, keys, last_values)
        expected = 'SELECT * FROM "public"."test"'

        self.assertEqual(result, expected)
Exemple #2
0
    def test_get_query_without_last_values(self):
        keys = ['col1', 'col2']
        last_values = None
        schema = 'public'
        table = 'test'

        result = get_query(schema, table, keys, last_values)
        expected = 'SELECT * FROM "public"."test" ' \
                   'ORDER BY "col1", "col2"'

        self.assertEqual(result, expected)
Exemple #3
0
    def test_get_query_with_multicolumn_index(self):
        keys = ['col1', 'col2']
        last_values = ['1', '2']
        schema = 'public'
        table = 'test'

        result = get_query(schema, table, keys, last_values)
        expected = 'SELECT * FROM "public"."test" ' \
                   'WHERE "col1" >= \'1\' AND "col2" >= \'2\' ' \
                   'ORDER BY "col1", "col2"'

        self.assertEqual(result, expected)
Exemple #4
0
    def test_orderby_with_incremental_key(self):
        inckey = 'pk3'
        incval = ''
        max_value = 10
        schema = 'public'
        table = 'test'

        result = get_query(
            schema,
            table,
            inckey,
            incval,
            max_value,
        )
        expected = 'SELECT * FROM "public"."test" ORDER BY "pk3"'

        self.assertEqual(result, expected)
Exemple #5
0
    def test_get_query_without_incremental(self):
        inckey = ''
        incval = ''
        schema = 'public'
        table = 'test'
        max_value = None

        result = get_query(
            schema,
            table,
            inckey,
            incval,
            max_value
        )
        expected = 'SELECT * FROM "public"."test"'

        self.assertEqual(result, expected)
Exemple #6
0
    def test_orderby_with_incremental_value(self):
        inckey = 'pk2'
        incval = '100'
        max_value = '200'
        schema = 'public'
        table = 'test'

        result = get_query(
            schema,
            table,
            inckey,
            incval,
            max_value
        )
        expected = 'SELECT * FROM "public"."test" WHERE ' \
                   '("pk2" >= \'100\' AND "pk2" <= \'200\') ORDER BY "pk2"'

        self.assertEqual(result, expected)