Example #1
0
def full_jelm_exporter():

    django_dump = get_django_dump_of_app("teach")

    el = Jelm(metadata={"created": datetime.datetime.now().isoformat()})
    plus_edges = []

    for django_record_dic in django_dump:

        record_inst = DjangoRecord.from_django_dump_record(django_record_dic)
        record_inst.add_jelm_nodes_to_instance(el)
        plus_edges += record_inst.jelm_edges()

    for e in plus_edges:
        el.add_object(e)

    return el.dict()
Example #2
0
    def add_edge_jelm_obj(el: Jelm):

        el.add_object(Edge(source="n1", target="n2", id="fing"))
        return el
Example #3
0
    def add_edge_as_obj(el: Jelm):

        el.add_object({"type": "edge", "source": "n1", "target": "n2"})
        return el
Example #4
0
    def add_node_as_obj(el: Jelm):

        el.add_object({"type": "node", "id": "n10"})
        return el
Example #5
0
def test_add_object():

    el = Jelm()

    el.add_object({"type": "node", "id": "n1"})

    el.add_object(Node(id="n2"))

    el.add_object({"type": "edge", "source": "n1", "target": "n2"})

    el.add_object(Node(id="n3", attributes={"priority": "low"}))

    with pytest.raises(ValueError):
        el.add_object({"no": "type"})

    with pytest.raises(ValueError):
        el.add_object({"type": "wrong"})

    with pytest.raises(ValueError):
        el.add_object(10)

    el.add_edge("n3", "n2")

    el.add_node("n4", {"order": "latest"})

    assert len(set([type(o) for o in el.objects])) > 1
    assert isinstance(el.objects[0], Node)
    assert isinstance(el.objects[2], Edge)