Пример #1
0
    def testEnumValuesCmp(self):
        FooType = enum.EnumClass('FooType', ('Foo', 'Foobie'))
        BarType = enum.EnumClass('BarType', ('Bar', 'Barrie'))

        # FooType with FooType
        self.assertEquals(FooType.Foo, FooType.Foo)
        self.assertNotEquals(FooType.Foo, FooType.Foobie)
        self.assertNotEquals(FooType.Foobie, FooType.Foo)
        self.assertEquals(FooType.Foobie, FooType.Foobie)

        # BarType with BarType
        self.assertEquals(BarType.Bar, BarType.Bar)
        self.assertNotEquals(BarType.Bar, BarType.Barrie)
        self.assertNotEquals(BarType.Barrie, BarType.Bar)
        self.assertEquals(BarType.Barrie, BarType.Barrie)

        # FooType with BarType
        self.assertNotEquals(FooType.Foo, BarType.Bar)
        self.assertNotEquals(FooType.Foo, BarType.Barrie)
        self.assertNotEquals(FooType.Foobie, BarType.Bar)
        self.assertNotEquals(FooType.Foobie, BarType.Barrie)

        # BarType with FooType
        self.assertNotEquals(BarType.Bar, FooType.Foo)
        self.assertNotEquals(BarType.Bar, FooType.Foobie)
        self.assertNotEquals(BarType.Barrie, FooType.Foo)
        self.assertNotEquals(BarType.Barrie, FooType.Foobie)
Пример #2
0
    def testEnumValuesWithRepr(self):
        en = enum.EnumClass(
            'TestEnum', ('Zero', 'One', 'Two'),
            ('This is the first', 'This is the second', 'This is the third'))
        self.assertEquals(len(en), 3)
        self.failUnless(issubclass(en, enum.Enum))
        self.failUnless(hasattr(en, 'Zero'))
        self.failUnless(hasattr(en, 'One'))
        self.failUnless(hasattr(en, 'Two'))

        e0 = en.Zero
        e1 = en.One
        e2 = en.Two
        self.assertEquals(e0.value, 0)
        self.assertEquals(e1.value, 1)
        self.assertEquals(e2.value, 2)
        self.assertEquals(e0.name, 'Zero')
        self.assertEquals(e1.name, 'One')
        self.assertEquals(e2.name, 'Two')
        self.assertEquals(e0.nick, 'This is the first')
        self.assertEquals(e1.nick, 'This is the second')
        self.assertEquals(e2.nick, 'This is the third')

        self.assertEquals(en.get(0), e0)
        self.assertEquals(en.get(1), e1)
        self.assertEquals(en.get(2), e2)

        self.assertEquals(tuple(en), (e0, e1, e2))
Пример #3
0
 def testEnumValues(self):
     en = enum.EnumClass('TestEnum', ('Zero', 'One', 'Two'))
     self.assertEquals(en.__name__, 'TestEnum')
     self.assertEquals(len(en), 3)
     self.assertEquals(en.get(0).name, 'Zero')
     self.assertEquals(en.get(1).name, 'One')
     self.assertEquals(en.get(2).name, 'Two')
     self.assertRaises(StopIteration, en.__getitem__, 3)
Пример #4
0
    """
    def invalidate(self):
        for component in self.get('components'):
            component.invalidate()

        flavors.StateRemoteCache.invalidate(self)


pb.setUnjellyableForClass(ManagerFlowState, AdminFlowState)

# moods
# FIXME. make epydoc like this
"""
@cvar moods: an enum representing the mood a component can be in.
"""
moods = enum.EnumClass(
    'Moods', ('happy', 'hungry', 'waking', 'sleeping', 'lost', 'sad'))
moods.can_stop = staticmethod(lambda m: m != moods.sleeping)
moods.can_start = staticmethod(lambda m: m == moods.sleeping)

_jobStateKeys = ['mood', 'manager-ip', 'pid', 'workerName']
_jobStateListKeys = [
    'messages',
]

# FIXME: maybe make Atmosphere and Flow subclass from a ComponentGroup class ?


class ManagerComponentState(flavors.StateCacheable):
    """
    I represent the state of a component in the manager.
    I have my own state, and also proxy state from the L{ManagerJobState}
Пример #5
0
from flumotion.component.base.baseadminnode import BaseAdminGtkNode
from flumotion.ui import fgtk

__version__ = "$Rev$"

VideoTestPattern = enum.EnumClass('VideoTestPattern', [
    'Bars', 'Snow', 'Black', 'White', 'Red', 'Green', 'Blue', 'Checkers-1',
    'Checkers-2', 'Checkers-4', 'Checkers-8', 'Circular', 'Blink', 'Bars 75%',
    'Zone-plate'
], [
    _('SMPTE 100% color bars'),
    _('Random (television snow)'),
    _('100% Black'),
    _('100% White'),
    _('100% Red'),
    _('100% Green'),
    _('100% Blue'),
    _('Checkers 1px'),
    _('Checkers 2px'),
    _('Checkers 4px'),
    _('Checkers 8px'),
    _('Circular'),
    _('Blink'),
    _('SMPTE 75% color bars'),
    _('Zone plate')
])


class PatternNode(BaseAdminGtkNode):
    uiStateHandlers = None
Пример #6
0
 def testEnumSimple(self):
     en = enum.EnumClass('TestEnum')
     self.assertEquals(en.__name__, 'TestEnum')
     self.assertEquals(len(en), 0)
     self.assertRaises(KeyError, en.get, 0)
     self.assertRaises(StopIteration, en.__getitem__, 0)
Пример #7
0
 def testJelly(self):
     a = enum.EnumClass('FooType', ('Foo', 'Bar'))
     self.assertEquals(jelly.unjelly(jelly.jelly(a.Foo)), a.Foo)
     self.assertEquals(jelly.unjelly(jelly.jelly(a.Bar)), a.Bar)
     self.assertNotEquals(jelly.unjelly(jelly.jelly(a.Foo)), a.Bar)
     self.assertNotEquals(jelly.unjelly(jelly.jelly(a.Bar)), a.Foo)
Пример #8
0
 def testRepr(self):
     a = enum.EnumClass('FooType', ('Foo', 'Bar'))
     self.failUnless(repr(a.Foo))
     self.failUnless(isinstance(repr(a.Foo), str))
Пример #9
0
 def testEnumSet(self):
     FooType = enum.EnumClass('FooType', ('Foo', 'Bar'))
     FooType.set(0, FooType(3, 'Baz'))