'A call to /json/user_uploads should return a uri and actually create an object.'

@use_s3_backend
def test_file_upload_authed(self):

    conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY)
    conn.create_bucket(settings.S3_AUTH_UPLOADS_BUCKET)
    self.login(self.example_email('hamlet'))
    fp = StringIO('zulip!')
    fp.name = 'zulip.txt'
    result = self.client_post('/json/user_uploads', {'file': fp})
    self.assert_json_success(result)
    json = ujson.loads(result.content)
    self.assertIn('uri', json)
    uri = json['uri']
    base = '/user_uploads/'
    self.assertEqual(base, uri[:len(base)])
    response = self.client_get(uri)
    redirect_url = response['Location']
    self.assertEqual('zulip!', urllib.request.urlopen(redirect_url).read().strip())
    self.subscribe_to_stream(self.example_email('hamlet'), 'Denmark')
    body = (('First    message    ...[zulip.txt](http://localhost:9991' + uri) + ')')
    self.send_message(self.example_email('hamlet'), 'Denmark', Recipient.STREAM, body, 'test')
    self.assertIn('title="zulip.txt"', self.get_last_message().rendered_content)
