Example #1
0
 def test_print_item_locations_account_no_ring(self):
     out = StringIO()
     account = 'account'
     with mock.patch('sys.stdout', out):
         print_item_locations(None, account=account, swift_dir=self.testdir)
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertTrue(exp_acct_msg in out.getvalue())
     self.assertTrue(exp_cont_msg in out.getvalue())
     self.assertTrue(exp_obj_msg in out.getvalue())
Example #2
0
 def test_print_item_locations_account_no_ring(self):
     out = StringIO()
     account = 'account'
     with mock.patch('sys.stdout', out):
         print_item_locations(None, account=account,
                              swift_dir=self.testdir)
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertTrue(exp_acct_msg in out.getvalue())
     self.assertTrue(exp_cont_msg in out.getvalue())
     self.assertTrue(exp_obj_msg in out.getvalue())
Example #3
0
 def test_print_item_locations_account_container_ring(self):
     out = StringIO()
     account = 'account'
     container = 'container'
     with mock.patch('sys.stdout', out):
         container_ring = ring.Ring(self.testdir, ring_name='container')
         print_item_locations(container_ring, account=account,
                              container=container)
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\t%s' % container
     exp_obj_msg = 'Object   \tNone'
     self.assertTrue(exp_acct_msg in out.getvalue())
     self.assertTrue(exp_cont_msg in out.getvalue())
     self.assertTrue(exp_obj_msg in out.getvalue())
Example #4
0
 def test_print_item_locations_policy_object(self):
     out = StringIO()
     part = '1'
     with mock.patch('sys.stdout', out):
         print_item_locations(None, partition=part, policy_name='zero',
                              swift_dir=self.testdir)
     exp_part_msg = 'Partition\t%s' % part
     exp_acct_msg = 'Account  \tNone'
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertTrue(exp_part_msg in out.getvalue())
     self.assertTrue(exp_acct_msg in out.getvalue())
     self.assertTrue(exp_cont_msg in out.getvalue())
     self.assertTrue(exp_obj_msg in out.getvalue())
Example #5
0
 def test_print_item_locations_account_container_ring(self):
     out = StringIO()
     account = 'account'
     container = 'container'
     with mock.patch('sys.stdout', out):
         container_ring = ring.Ring(self.testdir, ring_name='container')
         print_item_locations(container_ring, account=account,
                              container=container)
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\t%s' % container
     exp_obj_msg = 'Object   \tNone'
     self.assertIn(exp_acct_msg, out.getvalue())
     self.assertIn(exp_cont_msg, out.getvalue())
     self.assertIn(exp_obj_msg, out.getvalue())
Example #6
0
 def test_print_item_locations_policy_object(self):
     out = StringIO()
     part = '1'
     with mock.patch('sys.stdout', out):
         print_item_locations(None, partition=part, policy_name='zero',
                              swift_dir=self.testdir)
     exp_part_msg = 'Partition\t%s' % part
     exp_acct_msg = 'Account  \tNone'
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertIn(exp_part_msg, out.getvalue())
     self.assertIn(exp_acct_msg, out.getvalue())
     self.assertIn(exp_cont_msg, out.getvalue())
     self.assertIn(exp_obj_msg, out.getvalue())
Example #7
0
 def test_print_item_locations_dashed_ring_name_partition(self):
     out = StringIO()
     part = '1'
     with mock.patch('sys.stdout', out):
         print_item_locations(None, policy_name='one',
                              ring_name='foo-bar', partition=part,
                              swift_dir=self.testdir)
     exp_part_msg = 'Partition\t%s' % part
     exp_acct_msg = 'Account  \tNone'
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertIn(exp_part_msg, out.getvalue())
     self.assertIn(exp_acct_msg, out.getvalue())
     self.assertIn(exp_cont_msg, out.getvalue())
     self.assertIn(exp_obj_msg, out.getvalue())
Example #8
0
 def test_print_item_locations_account_container_object_dashed_ring(self):
     out = StringIO()
     account = 'account'
     container = 'container'
     obj = 'object'
     with mock.patch('sys.stdout', out):
         object_ring = ring.Ring(self.testdir, ring_name='object-1')
         print_item_locations(object_ring, ring_name='object-1',
                              account=account, container=container,
                              obj=obj)
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\t%s' % container
     exp_obj_msg = 'Object   \t%s' % obj
     self.assertTrue(exp_acct_msg in out.getvalue())
     self.assertTrue(exp_cont_msg in out.getvalue())
     self.assertTrue(exp_obj_msg in out.getvalue())
Example #9
0
 def test_print_item_locations_account_container_object_dashed_ring(self):
     out = StringIO()
     account = 'account'
     container = 'container'
     obj = 'object'
     with mock.patch('sys.stdout', out):
         object_ring = ring.Ring(self.testdir, ring_name='object-1')
         print_item_locations(object_ring, ring_name='object-1',
                              account=account, container=container,
                              obj=obj)
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\t%s' % container
     exp_obj_msg = 'Object   \t%s' % obj
     self.assertIn(exp_acct_msg, out.getvalue())
     self.assertIn(exp_cont_msg, out.getvalue())
     self.assertIn(exp_obj_msg, out.getvalue())
Example #10
0
 def test_print_item_locations_account_with_ring(self):
     out = StringIO()
     account = 'account'
     with mock.patch('sys.stdout', out):
         account_ring = ring.Ring(self.testdir, ring_name=account)
         print_item_locations(account_ring, account=account)
     exp_msg = 'Account  \t%s' % account
     self.assertTrue(exp_msg in out.getvalue())
     exp_warning = 'Warning: account specified ' + \
                   'but ring not named "account"'
     self.assertTrue(exp_warning in out.getvalue())
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertTrue(exp_acct_msg in out.getvalue())
     self.assertTrue(exp_cont_msg in out.getvalue())
     self.assertTrue(exp_obj_msg in out.getvalue())
Example #11
0
 def test_print_item_locations_account_with_ring(self):
     out = StringIO()
     account = 'account'
     with mock.patch('sys.stdout', out):
         account_ring = ring.Ring(self.testdir, ring_name=account)
         print_item_locations(account_ring, account=account)
     exp_msg = 'Account  \t%s' % account
     self.assertIn(exp_msg, out.getvalue())
     exp_warning = 'Warning: account specified ' + \
                   'but ring not named "account"'
     self.assertIn(exp_warning, out.getvalue())
     exp_acct_msg = 'Account  \t%s' % account
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertIn(exp_acct_msg, out.getvalue())
     self.assertIn(exp_cont_msg, out.getvalue())
     self.assertIn(exp_obj_msg, out.getvalue())
Example #12
0
 def test_print_item_locations_dashed_ring_name_partition(self):
     out = StringIO()
     part = '1'
     with mock.patch('sys.stdout', out):
         print_item_locations(None,
                              policy_name='one',
                              ring_name='foo-bar',
                              partition=part,
                              swift_dir=self.testdir)
     exp_part_msg = 'Partition\t%s' % part
     exp_acct_msg = 'Account  \tNone'
     exp_cont_msg = 'Container\tNone'
     exp_obj_msg = 'Object   \tNone'
     self.assertTrue(exp_part_msg in out.getvalue())
     self.assertTrue(exp_acct_msg in out.getvalue())
     self.assertTrue(exp_cont_msg in out.getvalue())
     self.assertTrue(exp_obj_msg in out.getvalue())