def test_load_components():
    loaded = ctx.load_components([Implementation1, Implementation2, Implementation3])
    eq_(len(loaded), 3)

    assert_true(Implementation1 in loaded)
    assert_true(Implementation2 in loaded)
    assert_true(Implementation3 in loaded)
    assert_false(Interface1 in loaded)
    assert_false(Interface2 in loaded)
    assert_false(Interface3 in loaded)

    eq_(len(ctx.get_implementations(Interface1)), 2)
    eq_(len(ctx.get_implementations(Interface2)), 2)
def test_load_components():
    loaded = ctx.load_components(
        [Implementation1, Implementation2, Implementation3])
    eq_(len(loaded), 3)

    assert_true(Implementation1 in loaded)
    assert_true(Implementation2 in loaded)
    assert_true(Implementation3 in loaded)
    assert_false(Interface1 in loaded)
    assert_false(Interface2 in loaded)
    assert_false(Interface3 in loaded)

    eq_(len(ctx.get_implementations(Interface1)), 2)
    eq_(len(ctx.get_implementations(Interface2)), 2)
Exemple #3
0
 def by_object_type(cls, object_type):
     """
     Return all subscription types with the object type matching the given
     ``object_type``.
     """
     return [c for c in ctx.get_implementations(cls)
             if c.object_type is object_type]
Exemple #4
0
 def by_name(cls, name):
     """
     Return the subscription type with the given name.
     """
     for c in ctx.get_implementations(cls):
         if c.name == name:
             return c
Exemple #5
0
 def by_action(cls, action=None):
     """
     Return all subscription types which implement the given action.
     """
     if not isinstance(action, basestring):
         action = action.name
     return [c for c in ctx.get_implementations(cls) if action in c.actions]
Exemple #6
0
 def by_name(cls, name):
     """
     Return the subscription type with the given name.
     """
     for c in ctx.get_implementations(cls):
         if c.name == name:
             return c
     raise Exception('Found no action with name %r. actions: %r' % (name, [x.name for x in ctx.get_implementations(cls)]))
Exemple #7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy_schemadisplay import create_uml_graph, create_schema_graph
from sqlalchemy.orm import class_mapper
from sqlalchemy.orm.exc import UnmappedClassError
from inyoka.core.api import db, ctx, IResource
from inyoka.utils import flatten_iterator

models = list(
    flatten_iterator(
        x.models for x in ctx.get_implementations(IResource, instances=True)))

# lets find all the mappers in our model
mappers = []
tables = []
for model in models:
    try:
        mappers.append(class_mapper(model))
        tables.extend(mappers[-1].tables)
    except UnmappedClassError:
        continue

# pass them to the function and set some formatting options
uml = create_uml_graph(
    mappers,
    show_operations=False,  # not necessary in this case
    show_multiplicity_one=False  # some people like to see the ones, some don't
)
uml.write_png('uml.png')  # write out the file

schema = create_schema_graph(list(set(tables)))
Exemple #8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy_schemadisplay import create_uml_graph, create_schema_graph
from sqlalchemy.orm import class_mapper
from sqlalchemy.orm.exc import UnmappedClassError
from inyoka.core.api import db, ctx, IResource
from inyoka.utils import flatten_iterator

models = list(flatten_iterator(x.models for x in ctx.get_implementations(IResource, instances=True)))

# lets find all the mappers in our model
mappers = []
tables = []
for model in models:
    try:
        mappers.append(class_mapper(model))
        tables.extend(mappers[-1].tables)
    except UnmappedClassError:
        continue

# pass them to the function and set some formatting options
uml = create_uml_graph(mappers,
    show_operations=False, # not necessary in this case
    show_multiplicity_one=False # some people like to see the ones, some don't
)
uml.write_png('uml.png') # write out the file

schema = create_schema_graph(list(set(tables)))
schema.write_png('schema.png')