예제 #1
0
 def test_transform(self):
     try:
         DecimalField.register_lookup(Round)
         DecimalModel.objects.create(n1=Decimal('2.0'), n2=Decimal('0'))
         DecimalModel.objects.create(n1=Decimal('-1.0'), n2=Decimal('0'))
         objs = DecimalModel.objects.filter(n1__round__gt=0)
         self.assertQuerysetEqual(objs, [Decimal('2.0')], lambda a: a.n1)
     finally:
         DecimalField._unregister_lookup(Round)
예제 #2
0
 def test_transform(self):
     try:
         DecimalField.register_lookup(Round)
         DecimalModel.objects.create(n1=Decimal('2.0'), n2=Decimal('0'))
         DecimalModel.objects.create(n1=Decimal('-1.0'), n2=Decimal('0'))
         objs = DecimalModel.objects.filter(n1__round__gt=0)
         self.assertQuerysetEqual(objs, [Decimal('2.0')], lambda a: a.n1)
     finally:
         DecimalField._unregister_lookup(Round)
예제 #3
0
 def test_transform(self):
     try:
         DecimalField.register_lookup(ACos)
         DecimalModel.objects.create(n1=Decimal('0.5'), n2=Decimal('0'))
         DecimalModel.objects.create(n1=Decimal('-0.9'), n2=Decimal('0'))
         objs = DecimalModel.objects.filter(n1__acos__lt=2)
         self.assertQuerysetEqual(objs, [Decimal('0.5')], lambda a: a.n1)
     finally:
         DecimalField._unregister_lookup(ACos)
예제 #4
0
 def test_transform(self):
     try:
         DecimalField.register_lookup(Floor)
         DecimalModel.objects.create(n1=Decimal('5.4'), n2=Decimal('0'))
         DecimalModel.objects.create(n1=Decimal('3.4'), n2=Decimal('0'))
         objs = DecimalModel.objects.filter(n1__floor__gt=4)
         self.assertQuerysetEqual(objs, [Decimal('5.4')], lambda a: a.n1)
     finally:
         DecimalField._unregister_lookup(Floor)
예제 #5
0
 def test_transform(self):
     try:
         DecimalField.register_lookup(Floor)
         DecimalModel.objects.create(n1=Decimal('5.4'), n2=Decimal('0'))
         DecimalModel.objects.create(n1=Decimal('3.4'), n2=Decimal('0'))
         objs = DecimalModel.objects.filter(n1__floor__gt=4)
         self.assertQuerysetEqual(objs, [Decimal('5.4')], lambda a: a.n1)
     finally:
         DecimalField._unregister_lookup(Floor)
예제 #6
0
 def test_transform(self):
     try:
         DecimalField.register_lookup(Ceil)
         DecimalModel.objects.create(n1=Decimal('3.12'), n2=Decimal('0'))
         DecimalModel.objects.create(n1=Decimal('1.25'), n2=Decimal('0'))
         objs = DecimalModel.objects.filter(n1__ceil__gt=3)
         self.assertQuerysetEqual(objs, [Decimal('3.12')], lambda a: a.n1)
     finally:
         DecimalField._unregister_lookup(Ceil)
예제 #7
0
파일: test_cos.py 프로젝트: zzzalisa/django
 def test_transform(self):
     try:
         DecimalField.register_lookup(Cos)
         DecimalModel.objects.create(n1=Decimal('-8.0'), n2=Decimal('0'))
         DecimalModel.objects.create(n1=Decimal('3.14'), n2=Decimal('0'))
         objs = DecimalModel.objects.filter(n1__cos__gt=-0.2)
         self.assertQuerysetEqual(objs, [Decimal('-8.0')], lambda a: a.n1)
     finally:
         DecimalField._unregister_lookup(Cos)