コード例 #1
0
def test_create_ci_type_relation(session, client):
    ci_types = init_ci_types(2)
    relation_type = init_relation_type(1)[0]

    url = "/api/v0.1/ci_type_relations/{}/{}".format(*[x.id for x in ci_types])
    payload = {
        "relation_type_id": relation_type.id,
    }

    resp = client.post(url, json=payload)

    assert resp.status_code == 200
    assert resp.json["ctr_id"]

    ci_type_relations_id = resp.json["ctr_id"]
    ci_type_relation = CITypeRelation.get_by_id(ci_type_relations_id)
    assert ci_type_relation.parent_id == ci_types[0].id
    assert ci_type_relation.child_id == ci_types[1].id
    assert ci_type_relation.relation_type_id == relation_type.id
コード例 #2
0
ファイル: ci_type.py プロジェクト: russellPanda/cmdb-2
 def delete(_id):
     ctr = CITypeRelation.get_by_id(_id) or abort(
         404, "Type relation <{0}> is not found".format(_id))
     ctr.soft_delete()