예제 #1
0
def create_osf_node(title, parent=None):
    if parent:
        url = api_create_node(parent.id)
        resp = session.post(url, data={'title': title})
        assert resp.ok

        base = furl(resp.headers['Location'])
        new_node_id = base.path.segments[0]
        url = api_node_self(new_node_id)
        resp = session.get(url)
        assert resp.ok
        new_node_dict = resp.json()['data']
        return dict_to_remote_object(new_node_dict)
    else:
        url = api_create_node()
        resp = session.post(url, data={'title': title})
        assert resp.ok
        return dict_to_remote_object(resp.json()['data'])
예제 #2
0
def create_osf_node(title, parent=None):
    if parent:
        url = api_create_node(parent.id)
        resp = session.post(url, data={'title':title})
        assert resp.ok

        base = furl(resp.headers['Location'])
        new_node_id = base.path.segments[0]
        url = api_node_self(new_node_id)
        resp = session.get(url)
        assert resp.ok
        new_node_dict = resp.json()['data']
        return dict_to_remote_object(new_node_dict)
    else:
        url = api_create_node()
        resp = session.post(url, data={'title':title})
        assert resp.ok
        return dict_to_remote_object(resp.json()['data'])
예제 #3
0
def get_node_by_node_id(node_id):
    url = api_node_self(node_id)
    resp = session.get(url)
    assert resp.ok
    return dict_to_remote_object(resp.json()['data'])
예제 #4
0
def get_node_by_node_id(node_id):
    url = api_node_self(node_id)
    resp = session.get(url)
    assert resp.ok
    return dict_to_remote_object(resp.json()['data'])