コード例 #1
0
    def test_download_binary(self):
        httpretty.register_uri(GET, util.STORAGE_URL + '/contname/objectname',
            status=200, body='object content')

        o = SwiftestObject(self.client, 'contname', 'objectname')

        self.assertEqual(o.download_binary(), b'object content')
コード例 #2
0
    def test_download_string(self):
        httpretty.register_uri(GET, util.STORAGE_URL + '/contname/objectname',
            status=200, body='object content')

        o = SwiftestObject(self.client, 'contname', 'objectname')

        string = o.download_string(encoding='utf-8')
        self.assertEqual(string, u'object content')
コード例 #3
0
    def test_download_binary(self):
        httpretty.register_uri(GET,
                               util.STORAGE_URL + '/contname/objectname',
                               status=200,
                               body='object content')

        o = SwiftestObject(self.client, 'contname', 'objectname')

        self.assertEqual(o.download_binary(), b'object content')
コード例 #4
0
    def test_download_file(self):
        httpretty.register_uri(GET, util.STORAGE_URL + '/contname/objectname',
            status=200, body='object content')

        o = SwiftestObject(self.client, 'contname', 'objectname')

        dest = BytesIO()
        o.download_file(dest)
        self.assertEqual(dest.getvalue(), b'object content')
        dest.close()
コード例 #5
0
    def test_download_string(self):
        httpretty.register_uri(GET,
                               util.STORAGE_URL + '/contname/objectname',
                               status=200,
                               body='object content')

        o = SwiftestObject(self.client, 'contname', 'objectname')

        string = o.download_string(encoding='utf-8')
        self.assertEqual(string, u'object content')
コード例 #6
0
    def test_upload_string(self):
        httpretty.register_uri(PUT, util.STORAGE_URL + '/contname/newobject',
            status=201)

        o = SwiftestObject(self.client, 'contname', 'newobject')

        o.upload_string(b'something')

        req = httpretty.last_request()
        self.assertEqual('437b930db84b8079c2dd804a71936b5f', req.headers['ETag'])
        self.assertEqual(b'something', req.body)
コード例 #7
0
    def test_download_file(self):
        httpretty.register_uri(GET,
                               util.STORAGE_URL + '/contname/objectname',
                               status=200,
                               body='object content')

        o = SwiftestObject(self.client, 'contname', 'objectname')

        dest = BytesIO()
        o.download_file(dest)
        self.assertEqual(dest.getvalue(), b'object content')
        dest.close()
コード例 #8
0
    def test_upload_string(self):
        httpretty.register_uri(PUT,
                               util.STORAGE_URL + '/contname/newobject',
                               status=201)

        o = SwiftestObject(self.client, 'contname', 'newobject')

        o.upload_string(b'something')

        req = httpretty.last_request()
        self.assertEqual('437b930db84b8079c2dd804a71936b5f',
                         req.headers['ETag'])
        self.assertEqual(b'something', req.body)