コード例 #1
0
ファイル: tests.py プロジェクト: carriercomm/web-2
    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
ファイル: connection_api.py プロジェクト: carriercomm/web-2
    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
ファイル: connection_api.py プロジェクト: stacksync/web
    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