示例#1
0
    def test_compute_folder_size(self):
        d = '{"id":null,"parent_id":null,"filename":"root","is_folder":true,"status":null,"version":null,"checksum":null,"size":null,"mimetype":null,"is_root":true,"contents":[{"id":1,"parent_id":null,"filename":"create consumer_oauth.txt","is_folder":false,"status":"NEW","modified_at":"2014-07-04 12:42:21.238","version":1,"checksum":1249793342,"size":968,"mimetype":"text/x-python","chunks":[]},{"id":2,"parent_id":null,"filename":"carpeta","is_folder":true,"status":"NEW","modified_at":"2014-07-04 12:47:18.632","version":1,"checksum":0,"size":0,"mimetype":"inode/directory","is_root":false},{"id":9,"parent_id":null,"filename":"aa","is_folder":true,"status":"NEW","modified_at":"2014-07-21 13:22:21.797","version":1,"checksum":0,"size":0,"mimetype":"inode/directory","is_root":false}]}'
        json_content = json.loads(d)
        file_metadata_helper = FileMetadataHelper(json_content)
        total_size = file_metadata_helper.compute_size()

        self.assertEquals(total_size, 968)
示例#2
0
文件: tests.py 项目: stacksync/web
    def test_compute_folder_size(self):
        d = '{"id":null,"parent_id":null,"filename":"root","is_folder":true,"status":null,"version":null,"checksum":null,"size":null,"mimetype":null,"is_root":true,"contents":[{"id":1,"parent_id":null,"filename":"create consumer_oauth.txt","is_folder":false,"status":"NEW","modified_at":"2014-07-04 12:42:21.238","version":1,"checksum":1249793342,"size":968,"mimetype":"text/x-python","chunks":[]},{"id":2,"parent_id":null,"filename":"carpeta","is_folder":true,"status":"NEW","modified_at":"2014-07-04 12:47:18.632","version":1,"checksum":0,"size":0,"mimetype":"inode/directory","is_root":false},{"id":9,"parent_id":null,"filename":"aa","is_folder":true,"status":"NEW","modified_at":"2014-07-21 13:22:21.797","version":1,"checksum":0,"size":0,"mimetype":"inode/directory","is_root":false}]}'
        json_content = json.loads(d)
        file_metadata_helper = FileMetadataHelper(json_content)
        total_size = file_metadata_helper.compute_size()

        self.assertEquals(total_size, 968)
示例#3
0
    def metadata(self, folder_id, access_token_key, access_token_secret):
        url = self.DEFAULT_FOLDER_URL + folder_id +'/contents'
        headeroauth, headers = self.get_oauth_headers(access_token_key, access_token_secret)
        r = requests.get(url, auth=headeroauth, headers=headers, verify=False)
 
        folder_list = []
        file_list = []
        json_data = None
        if r.status_code == 200:
            json_data = r.json()
            file_metadata_helper = FileMetadataHelper(json_data)

            if folder_id != self.ROOT_FOLDER:
                file_metadata_helper.add_initial_subfolder_metadata(folder_list)

            file_metadata_helper.filter_metadata_by_type(file_list, folder_list)

        folder_list = folder_list + file_list        
        return folder_list
示例#4
0
    def metadata(self, folder_id, access_token_key, access_token_secret):
        url = self.DEFAULT_FOLDER_URL + folder_id + '/contents'
        headeroauth, headers = self.get_oauth_headers(access_token_key,
                                                      access_token_secret)
        r = requests.get(url, auth=headeroauth, headers=headers, verify=False)

        folder_list = []
        file_list = []
        json_data = None
        if r.status_code == 200:
            json_data = r.json()
            file_metadata_helper = FileMetadataHelper(json_data)

            if folder_id != self.ROOT_FOLDER:
                file_metadata_helper.add_initial_subfolder_metadata(
                    folder_list)

            file_metadata_helper.filter_metadata_by_type(
                file_list, folder_list)

        folder_list = folder_list + file_list
        return folder_list