Ejemplo n.º 1
0
 def test_check_order_by_raises_no_exception_when_given_colum_name_as_string_with_quotes(
         self, app):
     # When
     try:
         check_order_by('"venueId"')
     except ApiErrors:
         # Then
         assert pytest.fail("Should not fail with valid params")
Ejemplo n.º 2
0
 def test_check_order_by_raises_no_exception_when_given_sqlalchemy_func_random_expression(
         self, app):
     # When
     try:
         check_order_by(func.random())
     except ApiErrors:
         # Then
         assert pytest.fail("Should not fail with valid params")
Ejemplo n.º 3
0
 def test_check_order_by_raises_no_exception_when_given_sqlalchemy_column_list(
         self, app):
     # When
     try:
         check_order_by([Offer.id, Offer.venueId])
     except ApiErrors:
         # Then
         assert pytest.fail("Should not fail with valid params")
Ejemplo n.º 4
0
    def test_check_order_by_raises_an_exception_when_given_select_statement(
            self, app):
        # When
        with pytest.raises(ApiErrors) as e:
            check_order_by('select plop from offer')

        # Then
        assert 'order_by' in e.value.errors
Ejemplo n.º 5
0
    def test_check_order_by_raises_an_exception_when_given_list_containing_invalid_part(
            self, app):
        # When
        with pytest.raises(ApiErrors) as e:
            check_order_by([Offer.id, func.random(), 'select * from toto'])

        # Then
        assert 'order_by' in e.value.errors
Ejemplo n.º 6
0
 def test_check_order_by_raises_no_exception_when_given_coalesce_expression_in_string(
         self, app):
     # When
     try:
         check_order_by('COALESCE("Offer"."venueId" , id) ASC')
     except ApiErrors:
         # Then
         assert pytest.fail("Should not fail with valid params")
Ejemplo n.º 7
0
 def test_check_order_by_raises_no_exception_when_given_comma_separated_list_in_string(
         self, app):
     # When
     try:
         check_order_by('"Offer"."venueId" DESC, id ASC')
     except ApiErrors:
         # Then
         assert pytest.fail("Should not fail with valid params")
Ejemplo n.º 8
0
 def test_check_order_by_raises_no_exception_when_given_mixed_list(
         self, app):
     # When
     try:
         check_order_by(
             [Offer.id, Offer.venueId.desc(),
              func.random(), 'id'])
     except ApiErrors:
         # Then
         assert pytest.fail("Should not fail with valid params")
Ejemplo n.º 9
0
def find_offerer_bookings_paginated(offerer_id, search=None, order_by=None, page=1):
    query = _filter_bookings_by_offerer_id(offerer_id)

    if search:
        query = _filter_bookings_with_keywords_string(query, search)

    if order_by:
        check_order_by(order_by)
        query = query_with_order_by(query, order_by)

    bookings = query.paginate(int(page), per_page=10, error_out=False) \
        .items

    return bookings