def _agave_listing(self, system, file_path, **kwargs):
        """Returns a "listing" dict constructed with the response from Agave.

        :param str sytem: System id
        :param str file_path: Path to list

        :returns: A dict with information of the listed file and, when possible, 
        a list of :class:`~designsafe.apps.api.data.agave.files.AgaveFile` objects
        dict in the key ``children``
        :rtype: dict

        Notes:
        -----

            This should not be called directly. See py:meth:`listing(file_id)`
            for more information.
        """
        listing = AgaveFile.listing(system, file_path, self.agave_client, source="public", **kwargs)

        root_file = filter(lambda x: x.full_path == file_path, listing)

        default_pems = [
            {
                "username": self.username,
                "permission": {"read": True, "write": False, "execute": True},
                "recursive": True,
            }
        ]

        list_data = root_file[0].to_dict(default_pems=default_pems)
        list_data["children"] = [o.to_dict(default_pems=default_pems) for o in listing if o.full_path != file_path]

        return list_data
示例#2
0
    def test_listing(self):
        with open('designsafe/apps/api/fixtures/agave_home_listing.json') as f:
            listing_json = json.load(f)
        ac = mock.Mock(autospec = Agave)
        ac.files.list.return_value = listing_json
        file_path = '%s/%s' % (self.user.username, self.afile_json['path'])

        listing = AgaveFile.listing(settings.AGAVE_STORAGE_SYSTEM,
                                    file_path, agave_client = ac)

        ac.files.list.assert_called_with(systemId = settings.AGAVE_STORAGE_SYSTEM, filePath = file_path, limit = 100, offset = 0)
        for i, af in enumerate(listing):
            self.assertEqual(af.full_path, listing_json[i]['path'])
示例#3
0
    def test_listing(self):
        with open('designsafe/apps/api/fixtures/agave_home_listing.json') as f:
            listing_json = json.load(f)
        ac = mock.Mock(autospec=Agave)
        ac.files.list.return_value = listing_json
        file_path = '%s/%s' % (self.user.username, self.afile_json['path'])

        listing = AgaveFile.listing(settings.AGAVE_STORAGE_SYSTEM,
                                    file_path,
                                    agave_client=ac)

        ac.files.list.assert_called_with(
            systemId=settings.AGAVE_STORAGE_SYSTEM,
            filePath=file_path,
            limit=100,
            offset=0)
        for i, af in enumerate(listing):
            self.assertEqual(af.full_path, listing_json[i]['path'])
    def _agave_listing(self, system, file_path, **kwargs):
        """Returns a "listing" dict constructed with the response from Agave.

        :param str sytem: System id
        :param str file_path: Path to list

        :returns: A dict with information of the listed file and, when possible,
        a list of :class:`~designsafe.apps.api.data.agave.files.AgaveFile` objects
        dict in the key ``children``
        :rtype: dict

        Notes:
        -----

            This should not be called directly. See py:meth:`listing(file_id)`
            for more information.
        """
        listing = AgaveFile.listing(system,
                                    file_path,
                                    self.agave_client,
                                    source='public',
                                    **kwargs)

        root_file = filter(lambda x: x.full_path == file_path, listing)

        default_pems = [{
            'username': self.username,
            'permission': {
                'read': True,
                'write': False,
                'execute': True
            },
            'recursive': True
        }]

        list_data = root_file[0].to_dict(default_pems=default_pems)
        list_data['children'] = [
            o.to_dict(default_pems=default_pems) for o in listing
            if o.full_path != file_path
        ]

        return list_data