Projet

Général

Profil

test_integrite_base_arv.py

Fabrice Barconnière, 03/03/2016 08:26

Télécharger (881 octets)

 
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3

    
4
from arv.db.initialize import initialize_database
5
from arv.db.node import get_nodes
6
from pyeole.ihm import print_red
7

    
8
initialize_database()
9
same_tmpl_vertices = set()
10
for node in get_nodes():
11
    # si un noeud a plus d'un vertex pour un même tmpl_vertex
12
    tmpl_vertex_ids = []
13
    for vertex in node.vertices:
14
        tmpl_vertex = vertex.tmpl_vertex
15
        tmpl_vertex_id = tmpl_vertex.id
16
        if tmpl_vertex_id in tmpl_vertex_ids:
17
            same_tmpl_vertices.add((node, tmpl_vertex))
18
        else:
19
            tmpl_vertex_ids.append(tmpl_vertex_id)
20

    
21
if len(same_tmpl_vertices) != 0:
22
    print_red("Un node ne doit être associé qu'à un tmpl_vertex :")
23
for node, tmpl_vertex in same_tmpl_vertices:
24
    print_red('  - {} ({}) a plusieurs vertex pour un même tmpl_vertex {}'.format(node.name, node.uai, tmpl_vertex.name))