|
13 | 13 |
|
14 | 14 | """Object Store v1 API Library Tests""" |
15 | 15 |
|
| 16 | +import mock |
| 17 | + |
16 | 18 | from requests_mock.contrib import fixture |
17 | 19 |
|
18 | 20 | from keystoneclient import session |
@@ -175,30 +177,41 @@ class TestObject(TestObjectAPIv1): |
175 | 177 | def setUp(self): |
176 | 178 | super(TestObject, self).setUp() |
177 | 179 |
|
178 | | - def test_object_create(self): |
| 180 | + @mock.patch('openstackclient.api.object_store_v1.io.open') |
| 181 | + def base_object_create(self, file_contents, mock_open): |
| 182 | + mock_open.read.return_value = file_contents |
| 183 | + |
179 | 184 | headers = { |
180 | 185 | 'etag': 'youreit', |
181 | 186 | 'x-trans-id': '1qaz2wsx', |
182 | 187 | } |
| 188 | + # TODO(dtroyer): When requests_mock gains the ability to |
| 189 | + # match against request.body add this check |
| 190 | + # https://review.openstack.org/127316 |
183 | 191 | self.requests_mock.register_uri( |
184 | 192 | 'PUT', |
185 | | - FAKE_URL + '/qaz/requirements.txt', |
| 193 | + FAKE_URL + '/qaz/counter.txt', |
186 | 194 | headers=headers, |
| 195 | + # body=file_contents, |
187 | 196 | status_code=201, |
188 | 197 | ) |
189 | 198 | ret = self.api.object_create( |
190 | 199 | container='qaz', |
191 | | - object='requirements.txt', |
| 200 | + object='counter.txt', |
192 | 201 | ) |
193 | 202 | data = { |
194 | 203 | 'account': FAKE_ACCOUNT, |
195 | 204 | 'container': 'qaz', |
196 | | - 'object': 'requirements.txt', |
| 205 | + 'object': 'counter.txt', |
197 | 206 | 'etag': 'youreit', |
198 | 207 | 'x-trans-id': '1qaz2wsx', |
199 | 208 | } |
200 | 209 | self.assertEqual(data, ret) |
201 | 210 |
|
| 211 | + def test_object_create(self): |
| 212 | + self.base_object_create('111\n222\n333\n') |
| 213 | + self.base_object_create(bytes([0x31, 0x00, 0x0d, 0x0a, 0x7f, 0xff])) |
| 214 | + |
202 | 215 | def test_object_delete(self): |
203 | 216 | self.requests_mock.register_uri( |
204 | 217 | 'DELETE', |
|
0 commit comments