Beispiel #1
0
 def test_default_attrs(self):
     self.t(
         u'''
         digraph g1 {
             page="3,3";
             graph [rotate=90];
             node [shape=box, color="#0000ff"];
             edge [style=dashed];
             n1 -> n2 -> n3;
             n3 -> n1;
         }
     ''',
         Graph(strict=None,
               type=u'digraph',
               id=u'g1',
               stmts=[
                   DefAttrs(object=u'graph',
                            attrs=[Attr(name=u'page', value=u'"3,3"')]),
                   DefAttrs(object=u'graph',
                            attrs=[Attr(name=u'rotate', value=u'90')]),
                   DefAttrs(object=u'node',
                            attrs=[
                                Attr(name=u'shape', value=u'box'),
                                Attr(name=u'color', value=u'"#0000ff"')
                            ]),
                   DefAttrs(object=u'edge',
                            attrs=[Attr(name=u'style', value=u'dashed')]),
                   Edge(nodes=[u'n1', u'n2', u'n3'], attrs=[]),
                   Edge(nodes=[u'n3', u'n1'], attrs=[])
               ]))
Beispiel #2
0
 def test_connected_subgraph(self):
     self.t(
         u'''
         digraph g1 {
             n1 -> n2 ->
             subgraph n3 {
                 nn1 -> nn2 -> nn3;
                 nn3 -> nn1;
             };
             subgraph n3 {} -> n1;
         }
     ''',
         Graph(strict=None,
               type=u'digraph',
               id=u'g1',
               stmts=[
                   Edge(nodes=[
                       u'n1', u'n2',
                       SubGraph(id=u'n3',
                                stmts=[
                                    Edge(nodes=[u'nn1', u'nn2', u'nn3'],
                                         attrs=[]),
                                    Edge(nodes=[u'nn3', u'nn1'], attrs=[])
                                ])
                   ],
                        attrs=[]),
                   Edge(nodes=[SubGraph(id=u'n3', stmts=[]), u'n1'],
                        attrs=[])
               ]))
Beispiel #3
0
 def test_simple_cycle(self):
     self.t(
         u'''
         digraph g1 {
             n1 -> n2 [w=5];
             n2 -> n3 [w=10];
             n3 -> n1 [w=7];
         }
     ''',
         Graph(strict=None,
               type=u'digraph',
               id=u'g1',
               stmts=[
                   Edge(nodes=[u'n1', u'n2'],
                        attrs=[Attr(name=u'w', value=u'5')]),
                   Edge(nodes=[u'n2', u'n3'],
                        attrs=[Attr(name=u'w', value=u'10')]),
                   Edge(nodes=[u'n3', u'n1'],
                        attrs=[Attr(name=u'w', value=u'7')])
               ]))
Beispiel #4
0
def test_unicode_names():
    t(
        u'''
        digraph g1 {
            n1 -> "Медведь" [label="Поехали!"];
            "Медведь" -> n3 [label="Добро пожаловать!"];
            n3 -> n1 ["Водка"="Селёдка"];
        }
    ''',
        Graph(
            strict=None,
            type=u'digraph',
            id=u'g1',
            stmts=[
                Edge(nodes=[u'n1', u'"Медведь"'],
                     attrs=[Attr(name=u'label', value=u'"Поехали!"')]),
                Edge(nodes=[u'"Медведь"', u'n3'],
                     attrs=[Attr(name=u'label',
                                 value=u'"Добро пожаловать!"')]),
                Edge(nodes=[u'n3', u'n1'],
                     attrs=[Attr(name=u'"Водка"', value=u'"Селёдка"')])
            ]))
Beispiel #5
0
    def add_manytomany_relation(self, model, related_obj):
        if not related_obj.model in self.models:
            return
        """ Example from the relation to core.models.Node from User:
                           m2m_column_name: node_id
                              m2m_db_table: core_node_admins
                            m2m_field_name: node
                    m2m_reverse_field_name: user
                          m2m_reverse_name: user_id
             m2m_reverse_target_field_name: id
                     m2m_target_field_name: id

        (see also: python manage.py sqlall core)
        """
        field = related_obj.field
        table_name = field.m2m_db_table()
        node = self.manytomany_to_dotnode(field, table_name)
        self.append(node)
        #node = self.model_to_dotnode(model)
        assocA = Association(self.get_dotid(model), table_name, Edge('1', '*'))
        assocB = Association(table_name, self.get_dotid(related_obj.model),
                             Edge('*', '1'))
        self.append(assocA)
        self.append(assocB)
Beispiel #6
0
 def add_manytomany_relation(self, model, related_obj):
     if not related_obj.model in self.models:
         return
     assoc = Association(self.get_dotid(model),
                         self.get_dotid(related_obj.model), Edge('*', '*'))
     self.append(assoc)