예제 #1
0
 def test_json_length_type(self):
     results = list(
         JSONModel.objects.annotate(
             x=JSONLength('attrs'),
         ).filter(x__range=[3, 5]),
     )
     assert results == [self.obj]
예제 #2
0
 def test_json_length_path(self):
     results = list(
         JSONModel.objects.annotate(
             x=JSONLength('attrs', '$.sub'),
         ).values_list('x', flat=True),
     )
     assert results == [len(self.obj.attrs['sub'])]
예제 #3
0
 def test_json_length_path(self):
     results = list(
         JSONModel.objects.annotate(x=JSONLength("attrs", "$.sub")).values_list(
             "x", flat=True
         )
     )
     assert results == [len(self.obj.attrs["sub"])]
예제 #4
0
 def test_json_length(self):
     results = list(
         JSONModel.objects.annotate(x=JSONLength('attrs')).values_list(
             'x', flat=True))
     assert results == [len(self.obj.attrs)]
예제 #5
0
 def test_json_length_output_field(self):
     results = list(
         JSONModel.objects.annotate(x=JSONLength(
             "attrs", output_field=IntegerField())).values_list("x",
                                                                flat=True))
     assert results == [len(self.obj.attrs)]