Exemplo n.º 1
0
 def test_should_use_view__get_queryset__and_filter_it_with__filter_queryset(
         self):
     expected = (
         u'SELECT "tests_app_bittestmodel"."id", "tests_app_bittestmodel"."is_active" '
         u'FROM "tests_app_bittestmodel" '
         u'WHERE "tests_app_bittestmodel"."is_active" = True ')
     response = ListSqlQueryKeyBit().get_data(**self.kwargs)
     self.assertEqual(response, expected)
Exemplo n.º 2
0
class CustomListKeyConstructor(DefaultKeyConstructor):
    list_sql = ListSqlQueryKeyBit()
    pagination = PaginationKeyBit()
    updated_at = UpdatedAtKeyBit()

    print("List SQL", list_sql)
    print("pagination", pagination)
    print("updated_at", updated_at)
Exemplo n.º 3
0
    def test_should_use_view__get_queryset__and_filter_it_with__filter_queryset(self):
        expected = (u'SELECT "unit_bittestmodel"."id", "unit_bittestmodel"."is_active" '
                    u'FROM "unit_bittestmodel" '
                    u'WHERE "unit_bittestmodel"."is_active" = True{space}')

        space = ''
        expected = expected.format(space=space)
        response = ListSqlQueryKeyBit().get_data(**self.kwargs)
        self.assertEqual(response, expected)
Exemplo n.º 4
0
class CustomListKeyConstructor(DefaultKeyConstructor):
    """
    Used to compute cache key for a list of objects.
    """
    list_sql = ListSqlQueryKeyBit()
    pagination = PaginationKeyBit()
    updated_at = UpdatedAtKeyBit()
    user = UserKeyBit()
    all_query_params = QueryParamsKeyBit()
Exemplo n.º 5
0
 def test_should_use_view__get_queryset__and_filter_it_with__filter_queryset(self):
     expected = (u'SELECT "tests_app_bittestmodel"."id", "tests_app_bittestmodel"."is_active" '
                 u'FROM "tests_app_bittestmodel" '
                 u'WHERE "tests_app_bittestmodel"."is_active" = True{space}')
     if get_django_features()['has_odd_space_in_sql_query']:
         space = ' '
     else:
         space = ''
     expected = expected.format(space=space)
     response = ListSqlQueryKeyBit().get_data(**self.kwargs)
     self.assertEqual(response, expected)
Exemplo n.º 6
0
    def test_should_use_view__get_queryset__and_filter_it_with__filter_queryset(
            self):
        if django.VERSION >= (3, 1):
            expected = (
                'SELECT "unit_bittestmodel"."id", "unit_bittestmodel"."is_active" '
                'FROM "unit_bittestmodel" '
                'WHERE "unit_bittestmodel"."is_active"')
        else:
            expected = (
                'SELECT "unit_bittestmodel"."id", "unit_bittestmodel"."is_active" '
                'FROM "unit_bittestmodel" '
                'WHERE "unit_bittestmodel"."is_active" = True')

        response = ListSqlQueryKeyBit().get_data(**self.kwargs)
        self.assertEqual(response, expected)
Exemplo n.º 7
0
 def test_should_return_none_if_empty_result_set_raised(self):
     self.kwargs['view_instance'].filter_queryset = lambda x: x.filter(pk__in=[])
     response = ListSqlQueryKeyBit().get_data(**self.kwargs)
     self.assertEqual(response, None)
Exemplo n.º 8
0
class CustomListKeyConstructor(DefaultKeyConstructor):
    list_sql = ListSqlQueryKeyBit()
    pagination = PaginationKeyBit()
    updated_at = UpdatedAtKeyBit()