~gholt/swift/largefiles

« back to all changes in this revision

Viewing changes to test/unit/proxy/test_server.py

  • Committer: gholt
  • Date: 2010-09-30 19:09:06 UTC
  • mfrom: (70.2.13 swift)
  • Revision ID: gholt@rackspace.com-20100930190906-8lqitfm57h1j910u
Merged changes from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1016
1016
 
1017
1017
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
1018
1018
                                headers={'Content-Length': '0',
 
1019
                                          'X-Copy-From': 'c/o/o2'})
 
1020
            req.account = 'a'
 
1021
            proxy_server.http_connect = \
 
1022
                fake_http_connect(200, 200, 200, 200, 200, 201, 201, 201)
 
1023
                #                 acct cont acct cont objc obj  obj  obj
 
1024
            self.app.memcache.store = {}
 
1025
            resp = controller.PUT(req)
 
1026
            self.assertEquals(resp.status_int, 201)
 
1027
            self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2')
 
1028
 
 
1029
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
 
1030
                                headers={'Content-Length': '0',
1019
1031
                                          'X-Copy-From': '/c/o'})
1020
1032
            self.app.update_request(req)
1021
1033
            proxy_server.http_connect = \
1028
1040
 
1029
1041
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
1030
1042
                                headers={'Content-Length': '0',
 
1043
                                          'X-Copy-From': '/c/o/o2'})
 
1044
            req.account = 'a'
 
1045
            proxy_server.http_connect = \
 
1046
                fake_http_connect(200, 200, 200, 200, 200, 201, 201, 201)
 
1047
                #                 acct cont acct cont objc obj  obj  obj
 
1048
            self.app.memcache.store = {}
 
1049
            resp = controller.PUT(req)
 
1050
            self.assertEquals(resp.status_int, 201)
 
1051
            self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2')
 
1052
 
 
1053
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
 
1054
                                headers={'Content-Length': '0',
1031
1055
                                          'X-Copy-From': '/c/o'})
1032
1056
            self.app.update_request(req)
1033
1057
            proxy_server.http_connect = \
1073
1097
            self.assertEquals(resp.headers.get('x-object-meta-test'), 'testing')
1074
1098
            self.assertEquals(resp.headers.get('x-object-meta-ours'), 'okay')
1075
1099
 
 
1100
    def test_COPY(self):
 
1101
        with save_globals():
 
1102
            controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o')
 
1103
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
 
1104
                                headers={'Content-Length': '0'})
 
1105
            req.account = 'a'
 
1106
            proxy_server.http_connect = \
 
1107
                fake_http_connect(200, 200, 201, 201, 201)
 
1108
                #                 acct cont obj  obj  obj
 
1109
            resp = controller.PUT(req)
 
1110
            self.assertEquals(resp.status_int, 201)
 
1111
 
 
1112
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
 
1113
                                headers={'Destination': 'c/o'})
 
1114
            req.account = 'a'
 
1115
            proxy_server.http_connect = \
 
1116
                fake_http_connect(200, 200, 200, 200, 200, 201, 201, 201)
 
1117
                #                 acct cont acct cont objc obj  obj  obj
 
1118
            self.app.memcache.store = {}
 
1119
            resp = controller.COPY(req)
 
1120
            self.assertEquals(resp.status_int, 201)
 
1121
            self.assertEquals(resp.headers['x-copied-from'], 'c/o')
 
1122
 
 
1123
            req = Request.blank('/a/c/o/o2', environ={'REQUEST_METHOD': 'COPY'},
 
1124
                                headers={'Destination': 'c/o'})
 
1125
            req.account = 'a'
 
1126
            controller.object_name = 'o/o2'
 
1127
            proxy_server.http_connect = \
 
1128
                fake_http_connect(200, 200, 200, 200, 200, 201, 201, 201)
 
1129
                #                 acct cont acct cont objc obj  obj  obj
 
1130
            self.app.memcache.store = {}
 
1131
            resp = controller.COPY(req)
 
1132
            self.assertEquals(resp.status_int, 201)
 
1133
            self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2')
 
1134
 
 
1135
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
 
1136
                                headers={'Destination': '/c/o'})
 
1137
            req.account = 'a'
 
1138
            controller.object_name = 'o'
 
1139
            proxy_server.http_connect = \
 
1140
                fake_http_connect(200, 200, 200, 200, 200, 201, 201, 201)
 
1141
                #                 acct cont acct cont objc obj  obj  obj
 
1142
            self.app.memcache.store = {}
 
1143
            resp = controller.COPY(req)
 
1144
            self.assertEquals(resp.status_int, 201)
 
1145
            self.assertEquals(resp.headers['x-copied-from'], 'c/o')
 
1146
 
 
1147
            req = Request.blank('/a/c/o/o2', environ={'REQUEST_METHOD': 'COPY'},
 
1148
                                headers={'Destination': '/c/o'})
 
1149
            req.account = 'a'
 
1150
            controller.object_name = 'o/o2'
 
1151
            proxy_server.http_connect = \
 
1152
                fake_http_connect(200, 200, 200, 200, 200, 201, 201, 201)
 
1153
                #                 acct cont acct cont objc obj  obj  obj
 
1154
            self.app.memcache.store = {}
 
1155
            resp = controller.COPY(req)
 
1156
            self.assertEquals(resp.status_int, 201)
 
1157
            self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2')
 
1158
 
 
1159
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
 
1160
                                headers={'Destination': 'c_o'})
 
1161
            req.account = 'a'
 
1162
            controller.object_name = 'o'
 
1163
            proxy_server.http_connect = \
 
1164
                fake_http_connect(200, 200)
 
1165
                #                 acct cont
 
1166
            self.app.memcache.store = {}
 
1167
            resp = controller.COPY(req)
 
1168
            self.assertEquals(resp.status_int, 412)
 
1169
 
 
1170
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
 
1171
                                headers={'Destination': '/c/o'})
 
1172
            req.account = 'a'
 
1173
            controller.object_name = 'o'
 
1174
            proxy_server.http_connect = \
 
1175
                fake_http_connect(200, 200, 503, 503, 503)
 
1176
                #                 acct cont objc objc objc
 
1177
            self.app.memcache.store = {}
 
1178
            resp = controller.COPY(req)
 
1179
            self.assertEquals(resp.status_int, 503)
 
1180
 
 
1181
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
 
1182
                                headers={'Destination': '/c/o'})
 
1183
            req.account = 'a'
 
1184
            controller.object_name = 'o'
 
1185
            proxy_server.http_connect = \
 
1186
                fake_http_connect(200, 200, 404, 404, 404)
 
1187
                #                 acct cont objc objc objc
 
1188
            self.app.memcache.store = {}
 
1189
            resp = controller.COPY(req)
 
1190
            self.assertEquals(resp.status_int, 404)
 
1191
 
 
1192
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
 
1193
                                headers={'Destination': '/c/o'})
 
1194
            req.account = 'a'
 
1195
            controller.object_name = 'o'
 
1196
            proxy_server.http_connect = \
 
1197
                fake_http_connect(200, 200, 404, 404, 200, 201, 201, 201)
 
1198
                #                 acct cont objc objc objc obj  obj  obj
 
1199
            self.app.memcache.store = {}
 
1200
            resp = controller.COPY(req)
 
1201
            self.assertEquals(resp.status_int, 201)
 
1202
 
 
1203
            req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'},
 
1204
                                headers={'Destination': '/c/o',
 
1205
                                          'X-Object-Meta-Ours': 'okay'})
 
1206
            req.account = 'a'
 
1207
            controller.object_name = 'o'
 
1208
            proxy_server.http_connect = \
 
1209
                fake_http_connect(200, 200, 200, 201, 201, 201)
 
1210
                #                 acct cont objc obj  obj  obj
 
1211
            self.app.memcache.store = {}
 
1212
            resp = controller.COPY(req)
 
1213
            self.assertEquals(resp.status_int, 201)
 
1214
            self.assertEquals(resp.headers.get('x-object-meta-test'), 'testing')
 
1215
            self.assertEquals(resp.headers.get('x-object-meta-ours'), 'okay')
 
1216
 
1076
1217
    def test_chunked_put_and_a_bit_more(self):
1077
1218
        # Since we're starting up a lot here, we're going to test more than
1078
1219
        # just chunked puts; we're also going to test parts of