Skip to content

Commit

Permalink
fixes django backward compatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jokiefer committed Oct 17, 2024
1 parent c6585ff commit 4cce1d1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json

from django import VERSION
from django.test import Client, RequestFactory, TestCase

from atomic_operations.consts import (
Expand Down Expand Up @@ -195,8 +196,15 @@ def test_view_processing_with_valid_request(self):

self.assertEqual(RelatedModel.objects.get(pk=1),
BasicModel.objects.get(pk=2).to_one)
self.assertQuerySetEqual(RelatedModelTwo.objects.filter(pk__in=[1, 2]),
BasicModel.objects.get(pk=2).to_many.all())

major, minor, _, _, _ = VERSION
if int(major) <= 4 and int(minor) <= 1:
self.assertQuerysetEqual(RelatedModelTwo.objects.filter(pk__in=[1, 2]),
BasicModel.objects.get(pk=2).to_many.all())
else:
# with django 4.2 TransactionTestCase.assertQuerysetEqual() is deprecated in favor of assertQuerySetEqual().
self.assertQuerySetEqual(RelatedModelTwo.objects.filter(pk__in=[1, 2]),
BasicModel.objects.get(pk=2).to_many.all())

def test_bulk_view_processing_with_valid_request(self):
operations = [
Expand Down

0 comments on commit 4cce1d1

Please sign in to comment.