'Ensure that the query we use to get public streams successfully returns
a list of streams'

def test_public_streams_api(self):

    email = self.example_email('hamlet')
    realm = get_realm('zulip')
    self.login(email)
    result = self.client_get('/api/v1/streams?include_public=false', **self.api_auth(email))
    result2 = self.client_get('/api/v1/users/me/subscriptions', **self.api_auth(email))
    self.assert_json_success(result)
    json = ujson.loads(result.content)
    self.assertIn('streams', json)
    self.assertIsInstance(json['streams'], list)
    self.assert_json_success(result2)
    json2 = ujson.loads(result2.content)
    self.assertEqual(sorted([s['name'] for s in json['streams']]), sorted([s['name'] for s in json2['subscriptions']]))
    result = self.client_get('/api/v1/streams?include_public=true&include_subscribed=false', **self.api_auth(email))
    self.assert_json_success(result)
    json = ujson.loads(result.content)
    all_streams = [stream.name for stream in Stream.objects.filter(realm=realm)]
    self.assertEqual(sorted((s['name'] for s in json['streams'])), sorted(all_streams))
    result = self.client_get('/api/v1/streams?include_all_active=true', **self.api_auth(email))
    self.assertEqual(result.status_code, 400)
