コード例 #1
0
ファイル: test_passobj.py プロジェクト: schwabe/nevow
 def compoundTest(aCompound=formless.Compound([
     formless.String(label="firstname"),
     formless.String(label="lastname")
 ],
                                              label="Full Name"),
                  anInt=formless.Integer()):
     """Compound Test
     
     A test of a widget/controller which renders multiple fields, triggers multiple
     validators, but gathers the result into one method argument. There can
     be an additional validation step which validates that the compound data
     as a whole is valid.
     """
     return str
コード例 #2
0
ファイル: test_passobj.py プロジェクト: schwabe/nevow
    def setBreakpoint(breakpoint=formless.String()):
        """Set a breakpoint

        Set a breakpoint at the given filename and line number. String passed is equivalent
        to doing b(reak) ([file:]lineno | function) in pdb.
        """
        return None
コード例 #3
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
        class IBindingDefaults(formless.TypedInterface):
            def aMethod(foo=formless.String(default="The foo")):
                pass

            aMethod = formless.autocallable(aMethod)

            aProperty = formless.String(default="The property")
コード例 #4
0
    def testString(self):
        s = formless.String()
        self.assertEqual(process(s, ''), None)
        self.assertEqual(process(s, "Fooo"), "Fooo")
        self.assertEqual(process(s, "This is a string"), "This is a string")
        self.assertEqual(process(s, 'C\xc3\xa9sar'), 'C\xc3\xa9sar')

        s = formless.String(str=True)
        self.assertEqual(process(s, 'C\xc3\xa9sar'), 'C\u00e9sar')

        s = formless.String(required=True)
        self.assertRaises(formless.InputError, process, s, "")
        
        s = formless.String(required=False)
        self.assertEqual(process(s, "Bar"), "Bar")
        self.assertEqual(process(s, ""), None)
    
        s = formless.String()
        self.assertEqual(process(s, ' abc '), ' abc ')
        
        s = formless.String(strip=True, required=True)
        self.assertEqual(process(s, ' abc '), 'abc')
        self.assertEqual(process(s, '\t abc \t  \n '), 'abc')
        self.assertRaises(formless.InputError, process, s, ' ')
        
        s = formless.String(required=False, strip=True)
        self.assertEqual(process(s, ' abc '), 'abc')
        self.assertEqual(process(s, ' '), None)
コード例 #5
0
        class ITest(formless.TypedInterface):
            """Test that a property value on one form does not 'leak' into
            a property of the same name on another form.
            """
            foo = formless.String()

            def meth(foo = formless.String()):
                pass
            meth = formless.autocallable(meth)
コード例 #6
0
ファイル: test_formless.py プロジェクト: msdemlei/nevow
    def testString(self):
        s = formless.String()
        self.assertEqual(process(s, ''), None)
        self.assertEqual(process(s, "Fooo"), "Fooo")
        self.assertEqual(process(s, "This is a string"), "This is a string")
        self.assertEqual(process(s, b'C\xc3\xa9sar'), 'C\xc3\xa9sar')
        self.assertEqual(process(s, 'C\xc3\xa9sar'), 'C\xc3\xa9sar')

#       I'm not sure what functionality was intended here, and I can't
#       see how it was implemented.  Let's assume we don't want it
#       any more -- MD 2018-08
#        s = formless.String(str=True)
#        self.assertEqual(process(s, 'C\xc3\xa9sar'), 'C\u00e9sar')

        s = formless.String(required=True)
        self.assertRaises(formless.InputError, process, s, "")
        
        s = formless.String(required=False)
        self.assertEqual(process(s, "Bar"), "Bar")
        self.assertEqual(process(s, ""), None)
    
        s = formless.String()
        self.assertEqual(process(s, ' abc '), ' abc ')
        
        s = formless.String(strip=True, required=True)
        self.assertEqual(process(s, ' abc '), 'abc')
        self.assertEqual(process(s, '\t abc \t  \n '), 'abc')
        self.assertRaises(formless.InputError, process, s, ' ')
        
        s = formless.String(required=False, strip=True)
        self.assertEqual(process(s, ' abc '), 'abc')
        self.assertEqual(process(s, ' '), None)
コード例 #7
0
    def test_2_renderPropertyBinding(self):
        binding = formless.Property('goodbye', formless.String(
            label="Goodbye",
            description="Goodbye cruel world"))

        # Look up an IBindingRenderer, which will render the form and the typed
        renderer = iformless.IBindingRenderer(binding)
        def later(val):
            self.assertSubstring('<form ', val)
            self.assertSubstring('<input name="change" type="submit"', val)
            self.assertSubstring('name="goodbye"', val)
            self.assertSubstring('Goodbye', val)
            self.assertSubstring('Goodbye cruel world', val)
        return self.render(tags.invisible(data=binding, render=renderer)).addCallback(later)
コード例 #8
0
    def test_3_renderMethodBinding(self):
        binding = formless.MethodBinding('doit', formless.Method(
            returnValue=None,
            arguments=[formless.Argument('foo', formless.String(label="Foo"))],
            label="Do It",
            description="Do it to 'em all"))

        renderer = iformless.IBindingRenderer(binding)

        def later(val):
            self.assertSubstring('<form ', val)
            self.assertSubstring('Do It', val)
            self.assertSubstring("Do it to 'em all", val)
            self.assertSubstring("Foo", val)
            self.assertSubstring('name="foo"', val)
        return self.render(tags.invisible(data=binding, render=renderer)).addCallback(later)
コード例 #9
0
    def test_1_renderTyped(self):
        binding = formless.Property('hello', formless.String(
            label="Hello",
            description="Hello, world."))

        ## Look up a renderer specific to the type of our binding, typedValue;
        renderer = iformless.ITypedRenderer(
            binding.typedValue, None)

        ## But render the binding itself with this renderer
        ## The binding has the ".name" attribute we need
        def later(val):
            self.assertSubstring('hello', val)
            self.assertSubstring('Hello', val)
            self.assertSubstring('Hello, world.', val)
            self.failIfSubstring('</form>', val)
            self.failIfSubstring('<input type="submit"', val)
        return self.render(tags.invisible(data=binding, render=renderer)).addCallback(later)
コード例 #10
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def sig(abc=formless.String()):
     pass
コード例 #11
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def foo(abc=formless.String()):
     pass
コード例 #12
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def aMethod(aString=formless.String()):
     return None
コード例 #13
0
 def foo(foobar=formless.String()):
     """This is a description of foo"""
     pass
コード例 #14
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def meth(foo=formless.String()):
     pass
コード例 #15
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 class IThing(formless.TypedInterface):
     aString = formless.String(str=True)
コード例 #16
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 class Group(formless.TypedInterface):
     foo = formless.String()
コード例 #17
0
ファイル: test_passobj.py プロジェクト: schwabe/nevow
class IBar(formless.TypedInterface):
    bar = formless.String()
コード例 #18
0
ファイル: test_rend.py プロジェクト: schwabe/nevow
 class IDeferredProperty(formless.TypedInterface):
     d = formless.String()
コード例 #19
0
 def oneArg(self, someParam=formless.String()):
     pass
コード例 #20
0
 def foo(foobar=formless.String()):
     """
     Docstring label for foo
     Description for foo
     """
     pass
コード例 #21
0
 def bar(barbaz=formless.Integer(label="The Baz")):
     ## this has no docstring, make sure it doesn't fail
     return formless.String()
コード例 #22
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 class Uneditable(formless.TypedInterface):
     aProp = formless.String(description="the description",
                             immutable=True)
コード例 #23
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 class ITest(formless.TypedInterface):
     foo = formless.String()
コード例 #24
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def aMethod(foo=formless.String(default="The foo")):
     pass
コード例 #25
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def foo(foo=formless.String()):
     pass
コード例 #26
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def aMethod(foo=formless.String(default="NOTFOO")):
     pass
コード例 #27
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 class IStupid(formless.TypedInterface):
     foo = formless.String()
コード例 #28
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def bMethod(foo=formless.String(default="NOTBAR")):
     pass
コード例 #29
0
ファイル: test_freeform.py プロジェクト: msdemlei/nevow
 def foo(bar=formless.String()):
     return formless.String()
コード例 #30
0
 class Test(formless.TypedInterface):
     foo = formless.String()
     bar = formless.Text()
     baz = formless.Integer()
     quux = formless.Object(interface=_indirectOther())