Revision be53c2d9

b/snf-tools/synnefo_tools/burnin/pithos_tests.py
51 51
    containers = Proper(value=None)
52 52
    created_container = Proper(value=None)
53 53
    now_unformated = Proper(value=datetime.utcnow())
54
    obj_metakey = Proper(value=None)
54 55

  
55 56
    def test_005_account_head(self):
56 57
        """HEAD on pithos account"""
......
196 197
        self.assertEqual('our value', r[k])
197 198
        self.info('Container meta exists')
198 199

  
199
    # def test_050_stop_test(self):
200
    #     """STOP TESTING ALREADY"""
201
    #     self.assertTrue(False)
200
        self.obj_metakey = 'metakey%s' % random.randint(1000, 9999)
201
        obj = 'object%s' % random.randint(1000, 9999)
202
        pithos.create_object(obj)
203
        pithos.set_object_meta(obj, {self.obj_metakey: 'our value'})
204
        r = pithos.get_container_object_meta()
205
        self.assertIn('x-container-object-meta', r)
206
        self.assertIn(
207
            self.obj_metakey, r['x-container-object-meta'].lower())
208
        self.info('Container object meta exists')
209

  
210
    def test_025_container_get(self):
211
        """Test container GET"""
212
        pithos = self.clients.pithos
213

  
214
        r = pithos.container_get()
215
        self.assertEqual(r.status_code, 200)
216
        self.info('Status code is OK')
217

  
218
        fullLen = len(r.json)
219
        obj1 = 'test%s' % random.randint(1000, 9999)
220
        pithos.create_object(obj1)
221
        obj2 = 'test%s' % random.randint(1000, 9999)
222
        pithos.create_object(obj2)
223
        obj3 = 'another%s.test' % random.randint(1000, 9999)
224
        pithos.create_object(obj3)
225

  
226
        r = pithos.container_get(prefix='test')
227
        self.assertTrue(len(r.json) > 1)
228
        test_objects = [o for o in r.json if o['name'].startswith('test')]
229
        self.assertEqual(len(r.json), len(test_objects))
230
        self.info('Prefix is OK')
231

  
232
        r = pithos.container_get(limit=1)
233
        self.assertEqual(len(r.json), 1)
234
        self.info('Limit is OK')
235

  
236
        r = pithos.container_get(marker=obj3[:-5])
237
        self.assertTrue(len(r.json) > 1)
238
        aoobjects = [obj for obj in r.json if obj['name'] > obj3[:-5]]
239
        self.assertEqual(len(r.json), len(aoobjects))
240
        self.info('Marker is OK')
241

  
242
        r = pithos.container_get(prefix=obj3, delimiter='.')
243
        self.assertTrue(fullLen > len(r.json))
244
        self.info('Delimiter is OK')
245

  
246
        r = pithos.container_get(path='/')
247
        fullLen += 3
248
        self.assertEqual(fullLen, len(r.json))
249
        self.info('Path is OK')
250

  
251
        r = pithos.container_get(format='xml')
252
        self.assertEqual(r.text.split()[4], 'name="' + pithos.container + '">')
253
        self.info('Format is OK')
254

  
255
        r = pithos.container_get(meta=[self.obj_metakey, ])
256
        self.assertTrue(len(r.json) > 0)
257
        self.info('Meta is OK')
258

  
259
        r = pithos.container_get(show_only_shared=True)
260
        self.assertTrue(len(r.json) < fullLen)
261
        self.info('Show-only-shared is OK')
262

  
263
        try:
264
            r = pithos.container_get(until=1000000000)
265
            datestring = unicode(r.headers['x-account-until-timestamp'])
266
            self.assertEqual(u'Sun, 09 Sep 2001 01:46:40 GMT', datestring)
267
            self.info('Until is OK')
268
        except ClientError:
269
            pass
270

  
271
    def test_050_stop_test(self):
272
        """STOP TESTING ALREADY"""
273
        self.assertTrue(False)
202 274

  
203 275
    def test_051_list_containers(self):
204 276
        """Test container list actually returns containers"""
......
285 357
    @classmethod
286 358
    def tearDownClass(cls):  # noqa
287 359
        """Clean up"""
360
        from kamaki.cli.logger import deactivate
361
        deactivate('kamaki.clients.send')
362
        deactivate('kamaki.clients.recv')
288 363
        pithos = cls.clients.pithos
289 364
        for c in getattr(cls, 'temp_containers', []):
290 365
            pithos.container = c

Also available in: Unified diff