def test_delete_ci_relation_by_id(session, client):
    cr_id = init_ci_relation()
    url = "/api/v0.1/ci_relations/{cr_id}".format(cr_id=cr_id)
    resp = client.delete(url)
    assert resp.status_code == 200
    cr = CIRelation.get_by_id(cr_id)
    assert cr is None
Beispiel #2
0
    def delete(cr_id):
        cr = CIRelation.get_by_id(cr_id) or abort(404, "CIRelation <{0}> is not existed".format(cr_id))
        cr.soft_delete()

        his_manager = CIRelationHistoryManager()
        his_manager.add(cr, operate_type=OperateType.DELETE)

        return cr_id
def test_delte_ci_relation_by_ci_id(session, client):
    cr_id = init_ci_relation()
    cis = CI.query.all()

    url = "/api/v0.1/ci_relations/{}/{}".format(cis[0].id, cis[1].id)
    resp = client.delete(url)
    assert resp.status_code == 200
    cr = CIRelation.get_by_id(cr_id)
    assert cr is None
Beispiel #4
0
    def delete(cr_id):
        cr = CIRelation.get_by_id(cr_id) or abort(404, "CIRelation <{0}> is not existed".format(cr_id))
        cr.delete()

        his_manager = CIRelationHistoryManager()
        his_manager.add(cr, operate_type=OperateType.DELETE)

        ci_relation_delete.apply_async(args=(cr.first_ci_id, cr.second_ci_id), queue=CMDB_QUEUE)

        return cr_id
def test_create_ci_relation(session, client):
    init_ci_type_relation(1)
    ci_types = CIType.query.all()
    cis = init_ci_with_type(ci_types)

    url = "/api/v0.1/ci_relations/{}/{}".format(cis[0]['ci_id'], cis[1]['ci_id'])

    resp = client.post(url)
    assert resp.status_code == 200
    cr_id = resp.json['cr_id']
    cr = CIRelation.get_by_id(cr_id)
    assert cr is not None