Beispiel #1
0
def test_make_plural_is_working_properly():
    """testing if stalker.models.make_plural() function is working properly
    """
    from stalker.models import make_plural
    test_words = [('asset', 'assets'), ('client', 'clients'),
                  ('department', 'departments'), ('entity', 'entities'),
                  ('template', 'templates'), ('group', 'groups'),
                  ('format', 'formats'), ('link', 'links'),
                  ('session', 'sessions'), ('note', 'notes'),
                  ('permission', 'permissions'), ('project', 'projects'),
                  ('repository', 'repositories'), ('review', 'reviews'),
                  ('scene', 'scenes'), ('sequence', 'sequences'),
                  ('shot', 'shots'), ('status', 'statuses'), ('list', 'lists'),
                  ('structure', 'structures'), ('studio', 'studios'),
                  ('tag', 'tags'), ('task', 'tasks'),
                  ('dependency', 'dependencies'), ('type', 'types'),
                  ('bench', 'benches'), ('thief', 'thieves')]
    for t, e in test_words:
        r = make_plural(t)
        assert r == e
Beispiel #2
0
def create_secondary_table(
        primary_cls_name,
        secondary_cls_name,
        primary_cls_table_name,
        secondary_cls_table_name,
        secondary_table_name=None):
    """creates any secondary table
    """
    plural_secondary_cls_name = make_plural(secondary_cls_name)

    # use the given class_name and the class_table
    if not secondary_table_name:
        secondary_table_name = '%s_%s' % (primary_cls_name,
                                          plural_secondary_cls_name)

    # check if the table is already defined
    if secondary_table_name not in Base.metadata:
        secondary_table = Table(
            secondary_table_name, Base.metadata,
            Column(
                '%s_id' % primary_cls_name.lower(),
                Integer,
                ForeignKey('%s.id' % primary_cls_table_name),
                primary_key=True,
            ),

            Column(
                '%s_id' % secondary_cls_name.lower(),
                Integer,
                ForeignKey('%s.id' % secondary_cls_table_name),
                primary_key=True,
            )
        )
    else:
        secondary_table = Base.metadata.tables[secondary_table_name]

    return secondary_table
 def test_make_plural_is_working_properly(self):
     """testing if stalker.models.make_plural() function is working properly
     """
     from stalker.models import make_plural
     test_words = [
         ('asset', 'assets'),
         ('client', 'clients'),
         ('department', 'departments'),
         ('entity', 'entities'),
         ('template', 'templates'),
         ('group', 'groups'),
         ('format', 'formats'),
         ('link', 'links'),
         ('session', 'sessions'),
         ('note', 'notes'),
         ('permission', 'permissions'),
         ('project', 'projects'),
         ('repository', 'repositories'),
         ('review', 'reviews'),
         ('scene', 'scenes'),
         ('sequence', 'sequences'),
         ('shot', 'shots'),
         ('status', 'statuses'),
         ('list', 'lists'),
         ('structure', 'structures'),
         ('studio', 'studios'),
         ('tag', 'tags'),
         ('task', 'tasks'),
         ('dependency', 'dependencies'),
         ('type', 'types'),
         ('bench', 'benches'),
         ('thief', 'thieves')
     ]
     for t, e in test_words:
         r = make_plural(t)
         self.assertEqual(r, e)
Beispiel #4
0
 def plural_class_name(self):
     """the plural name of this class
     """
     return make_plural(self.__class__.__name__)
Beispiel #5
0
 def plural_class_name(self):
     """the plural name of this class
     """
     return make_plural(self.__class__.__name__)