

def test_custom_metadata(self):
    account = self.conn.object_store.get_account_metadata()
    self.assertFalse(account.metadata)
    self.conn.object_store.set_account_metadata()
    account = self.conn.object_store.get_account_metadata()
    self.assertFalse(account.metadata)
    self.conn.object_store.set_account_metadata(k0='')
    account = self.conn.object_store.get_account_metadata()
    self.assertFalse(account.metadata)
    self.conn.object_store.set_account_metadata(k1='v1')
    account = self.conn.object_store.get_account_metadata()
    self.assertTrue(account.metadata)
    self.assertEqual(1, len(account.metadata))
    self.assertIn('k1', account.metadata)
    self.assertEqual('v1', account.metadata['k1'])
    self.conn.object_store.set_account_metadata(k2='v2')
    account = self.conn.object_store.get_account_metadata()
    self.assertTrue(account.metadata)
    self.assertEqual(2, len(account.metadata))
    self.assertIn('k1', account.metadata)
    self.assertEqual('v1', account.metadata['k1'])
    self.assertIn('k2', account.metadata)
    self.assertEqual('v2', account.metadata['k2'])
    self.conn.object_store.set_account_metadata(k1='v1.1')
    account = self.conn.object_store.get_account_metadata()
    self.assertTrue(account.metadata)
    self.assertEqual(2, len(account.metadata))
    self.assertIn('k1', account.metadata)
    self.assertEqual('v1.1', account.metadata['k1'])
    self.assertIn('k2', account.metadata)
    self.assertEqual('v2', account.metadata['k2'])
    self.conn.object_store.delete_account_metadata(['k1'])
    account = self.conn.object_store.get_account_metadata()
    self.assertTrue(account.metadata)
    self.assertEqual(1, len(account.metadata))
    self.assertIn('k2', account.metadata)
    self.assertEqual('v2', account.metadata['k2'])

dataset/ETHPy150Open openstack/python-openstacksdk/openstack/tests/functional/object_store/v1/test_account.py TestAccount.test_custom_metadata/original