コード例 #1
0
ファイル: test_base.py プロジェクト: bussiere/xworkflows
    def test_creation(self):
        def blah(obj):  # pragma: no cover
            """doc for blah"""
            pass

        implem = base.ImplementationProperty(
            field_name='my_state', transition=self.foobar, workflow=None,
            implementation=blah)

        self.assertIn("'foobar'", repr(implem))
        self.assertIn("blah", repr(implem))
        self.assertIn('my_state', repr(implem))
        self.assertEqual('doc for blah', implem.__doc__)
コード例 #2
0
ファイル: test_base.py プロジェクト: bussiere/xworkflows
    def test_using(self):
        def blah(obj):  # pragma: no cover
            pass

        class MyClass(object):
            state = self.foo

        implem = base.ImplementationProperty(
            field_name='my_state', transition=self.foobar, workflow=None,
            implementation=blah)

        MyClass.foobar = implem
        self.assertEqual(implem, MyClass.foobar)

        o = MyClass()
        self.assertRaises(TypeError, getattr, o, 'foobar')
コード例 #3
0
ファイル: test_base.py プロジェクト: zorky/xworkflows
    def test_copy(self):
        def blah(obj):  # pragma: no cover
            """Doc for blah"""
            pass

        implem = base.ImplementationProperty(field_name='my_state',
                                             transition=self.foobar,
                                             workflow=None,
                                             implementation=blah)

        implem2 = implem.copy()
        self.assertEqual('my_state', implem2.field_name)
        self.assertEqual(self.foobar, implem2.transition)
        self.assertIsNone(implem2.workflow)
        self.assertEqual(blah, implem2.implementation)
        self.assertEqual("Doc for blah", implem2.__doc__)
        self.assertEqual({}, implem2.hooks)
コード例 #4
0
ファイル: test_base.py プロジェクト: zorky/xworkflows
    def test_copy_exclude_hooks(self):
        def blah(obj):  # pragma: no cover
            """Doc for blah"""
            pass

        @base.before_transition('foo')
        def hook():
            pass

        implem = base.ImplementationProperty(field_name='my_state',
                                             transition=self.foobar,
                                             workflow=None,
                                             implementation=blah)
        # Structure: {'before': [('foo', hook)]}
        h = hook.xworkflows_hook['before'][0][1]
        implem.add_hook(h)

        implem2 = implem.copy()
        self.assertEqual({}, implem2.hooks)