Esempio n. 1
0
    def test_count(self):
        c = DataConcept.objects.get(fields__model_name='title',
                                    fields__field_name='salary')

        json = {
            'context': {
                'field': 'tests.title.salary',
                'operator': 'gt',
                'value': '1000'
            },
            'view': [{
                'concept': c.id,
                'visible': True,
            }]
        }

        query = DataQuery(json)

        # Default tree is Employee so we should get 6 unique employee objects
        # regardless of distinct setting since all are distinct.
        self.assertEqual(query.count(), 6)
        self.assertEqual(query.count(distinct=False), 6)

        # Switching the tree should allow us to exercise the distinct keyword
        # since there are 3 titles all with the same 15,000 unit salary. We
        # need to eliminate the PK so that we are only getting salaries
        # back. Including the PK causes everything to be unique.
        self.assertEqual(query.count(tree='title', include_pk=False), 5)
        self.assertEqual(
            query.count(tree='title', include_pk=False, distinct=False), 7)
Esempio n. 2
0
    def test_count(self):
        c = DataConcept.objects.get(fields__model_name='title',
                                    fields__field_name='salary')

        json = {
            'context': {
                'field': 'tests.title.salary',
                'operator': 'gt',
                'value': '1000'
            },
            'view': [{
                'concept': c.id,
                'visible': True,
            }]
        }

        query = DataQuery(json)

        # Default tree is Employee so we should get 6 unique employee objects
        # regardless of distinct setting since all are distinct.
        self.assertEqual(query.count(), 6)
        self.assertEqual(query.count(distinct=False), 6)

        # Switching the tree should allow us to exercise the distinct keyword
        # since there are 3 titles all with the same 15,000 unit salary. We
        # need to eliminate the PK so that we are only getting salaries
        # back. Including the PK causes everything to be unique.
        self.assertEqual(query.count(tree='title', include_pk=False), 5)
        self.assertEqual(
            query.count(tree='title', include_pk=False, distinct=False), 7)