コード例 #1
0
ファイル: test_utils.py プロジェクト: crisbud/swiftonfile
    def test_get_account_metadata(self):
        def _mock_get_account_details(path):
            c_list = ['123', 'abc']
            c_count = 2
            return c_list, c_count

        orig_gad = utils.get_account_details
        utils.get_account_details = _mock_get_account_details
        td = tempfile.mkdtemp()
        try:
            exp_md = {
                utils.X_TYPE: (utils.ACCOUNT, 0),
                utils.X_TIMESTAMP:
                (utils.normalize_timestamp(os.path.getctime(td)), 0),
                utils.X_PUT_TIMESTAMP:
                (utils.normalize_timestamp(os.path.getmtime(td)), 0),
                utils.X_OBJECTS_COUNT: (0, 0),
                utils.X_BYTES_USED: (0, 0),
                utils.X_CONTAINER_COUNT: (2, 0),
            }
            md = utils.get_account_metadata(td)
            assert md == exp_md
        finally:
            utils.get_account_details = orig_gad
            os.rmdir(td)
コード例 #2
0
ファイル: DiskDir.py プロジェクト: navidshaikh/gluster-swift
 def initialize(self, timestamp):
     """
     Create and write metatdata to directory/account.
     :param metadata: Metadata to write.
     """
     metadata = get_account_metadata(self.datadir)
     metadata[X_TIMESTAMP] = timestamp
     write_metadata(self.datadir, metadata)
     self.metadata = metadata
コード例 #3
0
ファイル: DiskDir.py プロジェクト: zyt19941113/gluster-swift
 def initialize(self, timestamp):
     """
     Create and write metatdata to directory/account.
     :param metadata: Metadata to write.
     """
     metadata = get_account_metadata(self.datadir)
     metadata[X_TIMESTAMP] = (timestamp, 0)
     write_metadata(self.datadir, metadata)
     self.metadata = metadata
コード例 #4
0
ファイル: test_utils.py プロジェクト: gbraad/glusterfs
 def test_get_account_metadata(self):
     def _mock_get_account_details(path, memcache=None):
         c_list = [ '123', 'abc' ]
         c_count = 2
         return c_list, c_count
     td = tempfile.mkdtemp()
     orig_gad = utils.get_account_details
     utils.get_account_details = _mock_get_account_details
     try:
         exp_md = {
             utils.X_TYPE: (utils.ACCOUNT, 0),
             utils.X_TIMESTAMP: (normalize_timestamp(os.path.getctime(td)), 0),
             utils.X_PUT_TIMESTAMP: (normalize_timestamp(os.path.getmtime(td)), 0),
             utils.X_OBJECTS_COUNT: (0, 0),
             utils.X_BYTES_USED: (0, 0),
             utils.X_CONTAINER_COUNT: (2, 0),
             }
         md = utils.get_account_metadata(td)
         assert md == exp_md
     finally:
         utils.get_account_details = orig_gad
         os.rmdir(td)