Example #1
0
    def test_api_did(self):
        """ DID (API): Test external representation of DIDs """
        # add some dids
        add_did(self.scope_name, 'ext_parent', 'container', issuer='root', account=self.account_name, **self.vo)
        add_did(self.scope_name, 'ext_child', 'dataset', issuer='root', account=self.account_name, **self.vo)
        attachment = {'scope': self.scope_name, 'name': 'ext_parent',
                      'dids': [{'scope': self.scope_name, 'name': 'ext_child', 'type': 'DATASET'}]}
        attach_dids_to_dids([attachment], issuer='root', **self.vo)

        # test scope_list
        out = scope_list(self.scope_name, recursive=True, **self.vo)
        out = list(out)
        assert_not_equal(0, len(out))
        parent_found = False
        for did in out:
            assert_equal(did['scope'], self.scope_name)
            if did['parent'] is not None:
                parent_found = True
                assert_equal(did['parent']['scope'], self.scope_name)
        assert_true(parent_found)

        # test get_did
        add_did_to_followed(self.scope_name, 'ext_parent', self.account_name, **self.vo)
        out = get_users_following_did('ext_parent', self.scope_name, **self.vo)
        out = list(out)
        assert_not_equal(0, len(out))
        for user in out:
            assert_equal(user['user'], self.account_name)
Example #2
0
File: did.py Project: yiiyama/rucio
    def GET(self, scope, name):
        """
        Return all users following a specific DID.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            406 Not Acceptable
            404 Not Found

        :param name: The data identifier name.
        :param scope: The scope name.
        """
        header('Content-Type', 'application/json')
        try:
            # Get the users following a did and render it as json.
            for user in get_users_following_did(scope=scope, name=name):
                yield render_json(**user) + '\n'
        except DataIdentifierNotFound as error:
            raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0])
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error)
Example #3
0
    def test_api_did(self):
        """ DID (API): Test external representation of DIDs """
        # add some dids
        ext_parent = did_name_generator('container')
        ext_child = did_name_generator('dataset')
        add_did(self.scope_name,
                ext_parent,
                'container',
                issuer='root',
                account=self.account_name,
                **self.vo)
        add_did(self.scope_name,
                ext_child,
                'dataset',
                issuer='root',
                account=self.account_name,
                **self.vo)
        attachment = {
            'scope':
            self.scope_name,
            'name':
            ext_parent,
            'dids': [{
                'scope': self.scope_name,
                'name': ext_child,
                'type': 'DATASET'
            }]
        }
        attach_dids_to_dids([attachment], issuer='root', **self.vo)

        # test scope_list
        out = scope_list(self.scope_name, recursive=True, **self.vo)
        out = list(out)
        assert 0 != len(out)
        parent_found = False
        for did in out:
            assert did['scope'] == self.scope_name
            if did['parent'] is not None:
                parent_found = True
                assert did['parent']['scope'] == self.scope_name
        assert parent_found

        # test get_did
        add_did_to_followed(self.scope_name, ext_parent, self.account_name,
                            **self.vo)
        out = get_users_following_did(ext_parent, self.scope_name, **self.vo)
        out = list(out)
        assert 0 != len(out)
        for user in out:
            assert user['user'] == self.account_name
Example #4
0
 def generate(vo):
     for user in get_users_following_did(scope=scope, name=name, vo=vo):
         yield render_json(**user) + '\n'