def test_search_extra_data(self):
        """ tests the search_buidlings method used throughout the app for only
            returning active CanonicalBuilding BuildingSnapshot insts.
        """
        # arrange
        NUMBER_ACTIVE = 10  # if more than 10, then alpha sort puts 11 before 2
        NUMBER_PER_PAGE = 10
        for i in range(NUMBER_ACTIVE):
            cb = CanonicalBuilding(active=True)
            cb.save()
            b = SEEDFactory.building_snapshot(
                canonical_building=cb,
                tax_lot_id=i % "%s"
            )
            if i > 4:
                b.extra_data = {
                    'nearest national park': 'mt hood'
                }
            cb.canonical_snapshot = b
            cb.save()
            b.super_organization = self.org
            b.save()
        url = reverse_lazy("seed:search_buildings")
        # filters on DB column and extra_data json field
        post_data = {
            'filter_params': {
                'tax_lot_id': '7',
                'nearest national park': 'hood'
            },
            'number_per_page': NUMBER_PER_PAGE,
            'order_by': 'tax_lot_id',
            'page': 1,
            'q': '',
            'sort_reverse': False,
            'project_id': None,
        }

        # act
        response = self.client.post(
            url,
            content_type='application/json',
            data=json.dumps(post_data)
        )
        json_string = response.content
        data = json.loads(json_string)

        # assert
        self.assertEqual(data['status'], 'success')
        self.assertEqual(len(data['buildings']), 1)
        self.assertEqual(data['buildings'][0]['tax_lot_id'], '7')
        self.assertEqual(
            data['buildings'][0]['extra_data']['nearest national park'],
            'mt hood'
        )

        # sort reverse
        # arrange
        post_data['sort_reverse'] = True
        post_data['filter_params'] = {
            'nearest national park': 'hood'
        }

        # act
        response = self.client.post(
            url,
            content_type='application/json',
            data=json.dumps(post_data)
        )
        json_string = response.content
        data = json.loads(json_string)

        # assert
        self.assertEqual(data['status'], 'success')
        self.assertEqual(data['buildings'][0]['tax_lot_id'], '9')
        self.assertEqual(data['buildings'][4]['tax_lot_id'], '5')
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/tests/test_views.py/SearchViewTests.test_search_extra_data/swapped operands of `%`