File: test_gv.py

package info (click to toggle)
crmsh 5.0.0~rc1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,752 kB
  • sloc: python: 50,224; sh: 1,204; makefile: 254; xml: 243; exp: 234; awk: 22
file content (36 lines) | stat: -rw-r--r-- 889 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from __future__ import unicode_literals
# Copyright (C) 2015 Kristoffer Gronlund <kgronlund@suse.com>
# See COPYING for license information.


import re

from crmsh import crm_gv
from crmsh import cibconfig


def test_digits_ident():
    g = crm_gv.gv_types["dot"]()
    cibconfig.set_graph_attrs(g, ".")

    g.new_node("1a", top_node=True)
    g.new_attr("1a", 'label', "1a")
    g.new_node("a", top_node=True)
    g.new_attr("a", 'label', "a")

    expected = [
        'fontname="Helvetica";',
        'fontsize="11";',
        'compound="true";',
        '"1a" [label="1a"];',
        'a [label="a"];',
    ]
    out = '\n'.join(g.repr()).replace('\t', '')

    for line in re.match(
            r'^digraph G {\n\n(?P<expected>.*)\n}$', out, re.M | re.S
    ).group('expected').split('\n'):
        assert line in expected
        expected.remove(line)

    assert len(expected) == 0