How to use the catalogue.models.Application function in catalogue

To help you get started, we’ve selected a few catalogue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dbca-wa / oim-cms / catalogue / test_api.py View on Github external
def test_list_filter(self):
        url = '/catalogue/api/records/'
        params = {'format': 'json'}
        resp = self.client.get(url, data=params)
        unfiltered = json.loads(resp.content.decode('utf-8'))
        records = Record.objects.all()
        rec1, rec2 = records[0], records[1]
        # Generate an Application
        app = mixer.blend(Application, name='test')
        app.records.add(rec1)
        params = {'format': 'json', 'application__name': 'test'}
        resp = self.client.get(url, data=params)
        self.assertEqual(resp.status_code, 200)
        self.assertContains(resp, rec1.title)
        self.assertNotContains(resp, rec2.title)
        # The filtered response will be shorter than the unfiltered one.
        filtered = json.loads(resp.content.decode('utf-8'))
        self.assertTrue(len(unfiltered) > len(filtered))