'A PUT request to /json/realm/icon with a valid file should return a url
and actually create an realm icon.'

def test_valid_icons(self):

    for (fname, rfname) in self.correct_files:
        self.login(self.example_email('iago'))
        with get_test_image_file(fname) as fp:
            result = self.client_post('/json/realm/icon', {'file': fp})
        realm = get_realm('zulip')
        self.assert_json_success(result)
        json = ujson.loads(result.content)
        self.assertIn('icon_url', json)
        url = json['icon_url']
        base = ('/user_avatars/%s/realm/icon.png' % (realm.id,))
        self.assertEqual(base, url[:len(base)])
        if (rfname is not None):
            response = self.client_get(url)
            data = ''.join(response.streaming_content)
            self.assertEqual(Image.open(io.BytesIO(data)).size, (100, 100))
