예제 #1
0
    def test_option_values(self):
        """test for ancestor, associated and module options"""
        handler = DiadefsHandler(Config())
        df_h = DiaDefGenerator(Linker(PROJECT), handler)
        cl_config = Config()
        cl_config.classes = ['Specialization']
        cl_h = DiaDefGenerator(Linker(PROJECT), DiadefsHandler(cl_config))
        self.assertEquals((0, 0), df_h._get_levels())
        self.assertEquals(False, df_h.module_names)
        self.assertEquals((-1, -1), cl_h._get_levels())
        self.assertEquals(True, cl_h.module_names)
        for hndl in [df_h, cl_h]:
            hndl.config.all_ancestors = True
            hndl.config.all_associated = True
            hndl.config.module_names = True
            hndl._set_default_options()
            self.assertEquals((-1, -1), hndl._get_levels())
            self.assertEquals(True, hndl.module_names)
        handler = DiadefsHandler(Config())
        df_h = DiaDefGenerator(Linker(PROJECT), handler)
        cl_config = Config()
        cl_config.classes = ['Specialization']
        cl_h = DiaDefGenerator(Linker(PROJECT), DiadefsHandler(cl_config))
        for hndl in [df_h, cl_h]:
            hndl.config.show_ancestors = 2
            hndl.config.show_associated = 1
            hndl.config.module_names = False
            hndl._set_default_options()
            self.assertEquals((2, 1), hndl._get_levels())
            self.assertEquals(False, hndl.module_names)

    #def test_default_values(self):
        """test efault values for package or class diagrams"""
예제 #2
0
 def test_known_values1(self):
     dd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT)
     self.assertEquals(len(dd), 2)
     keys = [d.TYPE for d in dd]
     self.assertEquals(keys, ['package', 'class'])
     pd = dd[0]
     self.assertEquals(pd.title, 'packages No Name')
     modules = _process_modules(pd.objects)
     self.assertEquals(modules, [{
         'node': True,
         'name': 'data'
     }, {
         'node': True,
         'name': 'data.clientmodule_test'
     }, {
         'node': True,
         'name': 'data.suppliermodule_test'
     }])
     cd = dd[1]
     self.assertEquals(cd.title, 'classes No Name')
     classes = _process_classes(cd.objects)
     self.assertEquals(classes, [{
         'node': True,
         'name': 'Ancestor'
     }, {
         'node': True,
         'name': 'DoNothing'
     }, {
         'node': True,
         'name': 'Interface'
     }, {
         'node': True,
         'name': 'Specialization'
     }])
예제 #3
0
 def test_known_values2(self):
     HANDLER.config.module_names = False
     cd = ClassDiadefGenerator(Linker(PROJECT), HANDLER).class_diagram(
         PROJECT, 'data.clientmodule_test.Specialization')
     self.assertEqual(cd.title, 'data.clientmodule_test.Specialization')
     classes = _process_classes(cd.objects)
     self.assertEqual(classes, [(True, 'Ancestor'), (True, 'DoNothing'),
                                (True, 'Specialization')])
예제 #4
0
 def test_functional_relation_extraction(self):
     """functional test of relations extraction;
     different classes possibly in different modules"""
     # XXX should be catching pyreverse environnement problem but doesn't
     # pyreverse doesn't extracts the relations but this test ok
     project = MANAGER.project_from_files(['data'], astng_wrapper)
     handler = DiadefsHandler(Config())
     diadefs = handler.get_diadefs(project, Linker(project, tag=True))
     cd = diadefs[1]
     relations = _process_relations(cd.relationships)
     self.assertEquals(relations, self._should_rels)
예제 #5
0
 def test_known_values1(self):
     HANDLER.config.classes = ['Specialization']
     cdg = ClassDiadefGenerator(Linker(PROJECT), HANDLER)
     special = 'data.clientmodule_test.Specialization'
     cd = cdg.class_diagram(PROJECT, special)
     self.assertEqual(cd.title, special)
     classes = _process_classes(cd.objects)
     self.assertEqual(classes, [
         (True, 'data.clientmodule_test.Ancestor'),
         (True, special),
         (True, 'data.suppliermodule_test.DoNothing'),
     ])
예제 #6
0
 def test_known_values2(self):
     project = MANAGER.project_from_files(['data.clientmodule_test'],
                                          astng_wrapper)
     dd = DefaultDiadefGenerator(Linker(project), HANDLER).visit(project)
     self.assertEqual(len(dd), 1)
     keys = [d.TYPE for d in dd]
     self.assertEqual(keys, ['class'])
     cd = dd[0]
     self.assertEqual(cd.title, 'classes No Name')
     classes = _process_classes(cd.objects)
     self.assertEqual(classes, [(True, 'Ancestor'), (True, 'DoNothing'),
                                (True, 'Specialization')])
예제 #7
0
 def run(self, args):
     """checking arguments and run project"""
     if not args:
         print self.help()
         return
     project = self.manager.project_from_files(args, astng_wrapper)
     linker = Linker(project, tag=True)
     handler = DiadefsHandler(self.config)
     diadefs = handler.get_diadefs(project, linker)
     if self.config.output_format == "vcg":
         writer.VCGWriter(self.config).write(diadefs)
     else:
         writer.DotWriter(self.config).write(diadefs)
예제 #8
0
 def test_known_values1(self):
     dd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT)
     self.assertEqual(len(dd), 2)
     keys = [d.TYPE for d in dd]
     self.assertEqual(keys, ['package', 'class'])
     pd = dd[0]
     self.assertEqual(pd.title, 'packages No Name')
     modules = sorted([(isinstance(m.node, astng.Module), m.title)
                       for m in pd.objects])
     self.assertEqual(modules, [(True, 'data'),
                                (True, 'data.clientmodule_test'),
                                (True, 'data.suppliermodule_test')])
     cd = dd[1]
     self.assertEqual(cd.title, 'classes No Name')
     classes = _process_classes(cd.objects)
     self.assertEqual(classes, [(True, 'Ancestor'), (True, 'DoNothing'),
                                (True, 'Interface'),
                                (True, 'Specialization')])
예제 #9
0
파일: main.py 프로젝트: ondrocks/Framework
    def run(self, args):
        """checking arguments and run project"""
        if not args:
            print(self.help())
            return
        # insert current working directory to the python path to recognize
        # dependencies to local modules even if cwd is not in the PYTHONPATH
        sys.path.insert(0, os.getcwd())
        try:
            project = self.manager.project_from_files(args)
            linker = Linker(project, tag=True)
            handler = DiadefsHandler(self.config)
            diadefs = handler.get_diadefs(project, linker)
        finally:
            sys.path.pop(0)

        if self.config.output_format == "vcg":
            writer.VCGWriter(self.config).write(diadefs)
        else:
            writer.DotWriter(self.config).write(diadefs)
"""

import unittest

from logilab.astng.inspector import Linker
from logilab.common.testlib import TestCase, unittest_main

from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
from pylint.pyreverse.diagrams import set_counter
from pylint.pyreverse.writer import DotWriter

from pylint.pyreverse.utils import get_visibility
from utils import FileTC, build_file_case, get_project, Config

project = get_project('data')
linker = Linker(project)
set_counter(0)

config = Config()

handler = DiadefsHandler(config)
dd = DefaultDiadefGenerator(linker, handler).visit(project)
for diagram in dd:
    diagram.extract_relationships()


class DotWriterTC(FileTC):

    generated_files = (
        'packages_No_Name.dot',
        'classes_No_Name.dot',
예제 #11
0
 def __init__(self, project, inherited_interfaces=0, tag=False):
     Linker.__init__(self,project,inherited_interfaces,tag)
예제 #12
0
 def test_exctract_relations(self):
     """test extract_relations between classes"""
     cd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT)[1]
     cd.extract_relationships()
     relations = _process_relations(cd.relationships)
     self.assertEquals(relations, self._should_rels)