Пример #1
0
    def unshare_narrative(self, wsi=None, users=None):
        if (wsi is None):
            raise ValueError('"wsi" is required')
        if (users is None):
            raise ValueError('"users" is required')

        # First do the actual unsharing in the workspace.
        rpc = GenericClient(module='Workspace',
                            url=self.config['services']['Workspace'],
                            token=self.token)
        rpc.call_func('set_permissions', [{
            'id': wsi.id(),
            'new_permission': 'n',
            'users': users
        }])

        # Then ensure that the cache for this workspace is
        # refreshed.
        workspace_cache = PermissionsCache(
            workspace_url=self.config['services']['Workspace'],
            path=self.config['caches']['workspace']['path'],
            username=self.username,  # just use the token for now...
            token=self.token)
        workspace_cache.refresh_items([wsi.id()])

        pass
 def test_refresh(self):
     db_path = self.cfg['cache-directory'] + '/object_cache.db'
     test_table = [{
         'constructor': {
             'path': db_path,
             'workspace_url': self.cfg['workspace-url'],
             'token': self.token,
             'username': self.username
         },
         'add_items': [[[34742, 'eapearson', 'hi'],
                        [34599, 'eapearson', 'hello']]],
         'refresh_items': [[34742, 34599]]
     }]
     for test in test_table:
         try:
             cache = PermissionsCache(**test['constructor'])
             cache.initialize()
             cache.add_items(*test['add_items'])
             cache.refresh_items(*test['refresh_items'])
             items = cache.get_all_items()
             self.assertGreater(len(items), 0)
             self.assertTrue(True)
         except ValueError as err:
             self.assertTrue(False)