def test_nodespace_removal(fixed_nodenet):
    res, uid = micropsi.add_nodespace(fixed_nodenet, [100, 100], nodespace=None, name="testspace")
    res, n1_uid = micropsi.add_node(fixed_nodenet, 'Register', [100, 100], nodespace=uid, name="sub1")
    res, n2_uid = micropsi.add_node(fixed_nodenet, 'Register', [100, 200], nodespace=uid, name="sub2")
    micropsi.add_link(fixed_nodenet, n1_uid, 'gen', n2_uid, 'gen', weight=1, certainty=1)
    res, sub_uid = micropsi.add_nodespace(fixed_nodenet, [100, 100], nodespace=uid, name="subsubspace")
    micropsi.delete_nodespace(fixed_nodenet, uid)
    # assert that the nodespace is gone
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(uid)
    assert uid not in micropsi.nodenets[fixed_nodenet].data['nodespaces']
    # assert that the nodes it contained are gone
    assert not micropsi.nodenets[fixed_nodenet].is_node(n1_uid)
    assert n1_uid not in micropsi.nodenets[fixed_nodenet].data['nodes']
    assert not micropsi.nodenets[fixed_nodenet].is_node(n2_uid)
    assert n2_uid not in micropsi.nodenets[fixed_nodenet].data['nodes']
    # assert that the links between the deleted nodes are gone
    linked_node_uids = []
    for uid, link in micropsi.nodenets[fixed_nodenet].data['links'].items():
        linked_node_uids.append(link['source_node_uid'])
        linked_node_uids.append(link['target_node_uid'])
    assert n1_uid not in linked_node_uids
    assert n2_uid not in linked_node_uids
    # assert that sub-nodespaces are gone as well
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(sub_uid)
    assert sub_uid not in micropsi.nodenets[fixed_nodenet].data['nodespaces']
Beispiel #2
0
def test_nodespace_removal(fixed_nodenet):
    res, uid = micropsi.add_nodespace(fixed_nodenet, [100, 100],
                                      nodespace=None,
                                      name="testspace")
    res, n1_uid = micropsi.add_node(fixed_nodenet,
                                    'Register', [100, 100],
                                    nodespace=uid,
                                    name="sub1")
    res, n2_uid = micropsi.add_node(fixed_nodenet,
                                    'Register', [100, 200],
                                    nodespace=uid,
                                    name="sub2")
    micropsi.add_link(fixed_nodenet,
                      n1_uid,
                      'gen',
                      n2_uid,
                      'gen',
                      weight=1,
                      certainty=1)
    res, sub_uid = micropsi.add_nodespace(fixed_nodenet, [100, 100],
                                          nodespace=uid,
                                          name="subsubspace")
    micropsi.delete_nodespace(fixed_nodenet, uid)
    # assert that the nodespace is gone
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(uid)
    assert uid not in micropsi.nodenets[fixed_nodenet].get_data()['nodespaces']
    # assert that the nodes it contained are gone
    assert not micropsi.nodenets[fixed_nodenet].is_node(n1_uid)
    assert n1_uid not in micropsi.nodenets[fixed_nodenet].get_data()['nodes']
    assert not micropsi.nodenets[fixed_nodenet].is_node(n2_uid)
    assert n2_uid not in micropsi.nodenets[fixed_nodenet].get_data()['nodes']
    # assert that sub-nodespaces are gone as well
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(sub_uid)
    assert sub_uid not in micropsi.nodenets[fixed_nodenet].get_data(
    )['nodespaces']
def test_nodespace_removal(fixed_nodenet):
    res, uid = micropsi.add_nodespace(fixed_nodenet, [100, 100], nodespace=None, name="testspace")
    res, n1_uid = micropsi.add_node(fixed_nodenet, 'Register', [100, 100], nodespace=uid, name="sub1")
    res, n2_uid = micropsi.add_node(fixed_nodenet, 'Register', [100, 200], nodespace=uid, name="sub2")
    micropsi.add_link(fixed_nodenet, n1_uid, 'gen', n2_uid, 'gen', weight=1, certainty=1)
    res, sub_uid = micropsi.add_nodespace(fixed_nodenet, [100, 100], nodespace=uid, name="subsubspace")
    micropsi.delete_nodespace(fixed_nodenet, uid)
    # assert that the nodespace is gone
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(uid)
    assert uid not in micropsi.nodenets[fixed_nodenet].get_data()['nodespaces']
    # assert that the nodes it contained are gone
    assert not micropsi.nodenets[fixed_nodenet].is_node(n1_uid)
    assert n1_uid not in micropsi.nodenets[fixed_nodenet].get_data()['nodes']
    assert not micropsi.nodenets[fixed_nodenet].is_node(n2_uid)
    assert n2_uid not in micropsi.nodenets[fixed_nodenet].get_data()['nodes']
    # assert that sub-nodespaces are gone as well
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(sub_uid)
    assert sub_uid not in micropsi.nodenets[fixed_nodenet].get_data()['nodespaces']
Beispiel #4
0
def test_nodespace_removal(fixed_nodenet):
    res, uid = micropsi.add_nodespace(fixed_nodenet, [100, 100],
                                      nodespace=None,
                                      name="testspace")
    res, n1_uid = micropsi.add_node(fixed_nodenet,
                                    'Register', [100, 100],
                                    nodespace=uid,
                                    name="sub1")
    res, n2_uid = micropsi.add_node(fixed_nodenet,
                                    'Register', [100, 200],
                                    nodespace=uid,
                                    name="sub2")
    micropsi.add_link(fixed_nodenet,
                      n1_uid,
                      'gen',
                      n2_uid,
                      'gen',
                      weight=1,
                      certainty=1)
    res, sub_uid = micropsi.add_nodespace(fixed_nodenet, [100, 100],
                                          nodespace=uid,
                                          name="subsubspace")
    micropsi.delete_nodespace(fixed_nodenet, uid)
    # assert that the nodespace is gone
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(uid)
    assert uid not in micropsi.nodenets[fixed_nodenet].data['nodespaces']
    # assert that the nodes it contained are gone
    assert not micropsi.nodenets[fixed_nodenet].is_node(n1_uid)
    assert n1_uid not in micropsi.nodenets[fixed_nodenet].data['nodes']
    assert not micropsi.nodenets[fixed_nodenet].is_node(n2_uid)
    assert n2_uid not in micropsi.nodenets[fixed_nodenet].data['nodes']
    # assert that the links between the deleted nodes are gone
    linked_node_uids = []
    for uid, link in micropsi.nodenets[fixed_nodenet].data['links'].items():
        linked_node_uids.append(link['source_node_uid'])
        linked_node_uids.append(link['target_node_uid'])
    assert n1_uid not in linked_node_uids
    assert n2_uid not in linked_node_uids
    # assert that sub-nodespaces are gone as well
    assert not micropsi.nodenets[fixed_nodenet].is_nodespace(sub_uid)
    assert sub_uid not in micropsi.nodenets[fixed_nodenet].data['nodespaces']
Beispiel #5
0
def delete_nodespace(nodenet_uid, nodespace):
    return runtime.delete_nodespace(nodenet_uid, nodespace)
Beispiel #6
0
def delete_nodespace(nodenet_uid, nodespace):
    """ Delete the given nodespace and all its contents"""
    return runtime.delete_nodespace(nodenet_uid, nodespace)