Revision e3b8f796 kamaki/clients/pithos/test.py

b/kamaki/clients/pithos/test.py
428 428
        for k, v in kwargs.items():
429 429
            self.assertEqual(v, put.mock_calls[-1][2][k])
430 430

  
431
    @patch('%s.get' % pithos_pkg, return_value=FR())
432
    @patch('%s.set_param' % pithos_pkg)
433
    def test_list_objects(self, SP, get):
434
        FR.json = object_list
435
        acc = self.client.account
436
        cont = self.client.container
437
        SP = PC.set_param
438
        r = self.client.list_objects()
439
        for i in range(len(r)):
440
            self.assert_dicts_are_equal(r[i], object_list[i])
441
        self.assertEqual(get.mock_calls, [
442
            call('/%s/%s' % (acc, cont), success=(200, 204, 304, 404))])
443
        self.assertEqual(SP.mock_calls, [call('format', 'json')])
444
        FR.status_code = 304
445
        self.assertEqual(self.client.list_objects(), [])
446
        FR.status_code = 404
447
        self.assertRaises(ClientError, self.client.list_objects)
448

  
449
    @patch('%s.get' % pithos_pkg, return_value=FR())
450
    @patch('%s.set_param' % pithos_pkg)
451
    def test_list_objects_in_path(self, SP, get):
452
        FR.json = object_list
453
        path = '/some/awsome/path'
454
        acc = self.client.account
455
        cont = self.client.container
456
        SP = PC.set_param
457
        self.client.list_objects_in_path(path)
458
        self.assertEqual(get.mock_calls, [
459
            call('/%s/%s' % (acc, cont), success=(200, 204, 404))])
460
        self.assertEqual(SP.mock_calls, [
461
            call('format', 'json'), call('path', path)])
462
        FR.status_code = 404
463
        self.assertRaises(ClientError, self.client.list_objects)
464

  
465 431
    #  Pithos+ only methods
466 432

  
467 433
    @patch('%s.container_delete' % pithos_pkg, return_value=FR())

Also available in: Unified diff