Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))