Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions
MoinMoin._tests.test_wikiutil.TestExtensionInvoking Class Reference

List of all members.

Public Member Functions

def testInvoke
def testConstructors
def testFailing
def testAllDefault
def testInvokeComplex

Public Attributes

 constructed

Private Member Functions

def _test_invoke_bool
def _test_invoke_bool_def
def _test_invoke_int_None
def _test_invoke_float_None
def _test_invoke_float_required
def _test_invoke_choice
def _test_invoke_choicet
def _test_invoke_choice_required
def _test_trailing
def _test_arbitrary_kw

Detailed Description

Definition at line 702 of file test_wikiutil.py.


Member Function Documentation

def MoinMoin._tests.test_wikiutil.TestExtensionInvoking._test_arbitrary_kw (   self,
  expect,
  _kwargs = {} 
) [private]

Definition at line 734 of file test_wikiutil.py.

00734 
00735     def _test_arbitrary_kw(self, expect, _kwargs={}):
00736         assert _kwargs == expect

Here is the caller graph for this function:

Definition at line 703 of file test_wikiutil.py.

00703 
00704     def _test_invoke_bool(self, b=bool):
00705         assert b is False

Here is the caller graph for this function:

def MoinMoin._tests.test_wikiutil.TestExtensionInvoking._test_invoke_bool_def (   self,
  v = bool,
  b = False 
) [private]

Definition at line 706 of file test_wikiutil.py.

00706 
00707     def _test_invoke_bool_def(self, v=bool, b=False):
00708         assert b == v
00709         assert isinstance(b, bool)
00710         assert isinstance(v, bool)

Here is the caller graph for this function:

def MoinMoin._tests.test_wikiutil.TestExtensionInvoking._test_invoke_choice (   self,
  a,
  choice = [u'a',
  u,
  b,
  u,
  c 
) [private]

Definition at line 720 of file test_wikiutil.py.

00720 
00721     def _test_invoke_choice(self, a, choice=[u'a', u'b', u'c']):
00722         assert a == 7
00723         assert choice == u'a'

Here is the caller graph for this function:

Definition at line 728 of file test_wikiutil.py.

00728 
00729     def _test_invoke_choice_required(self, i=wikiutil.required_arg((u'b', u'a'))):
00730         assert i == u'a'

Here is the caller graph for this function:

def MoinMoin._tests.test_wikiutil.TestExtensionInvoking._test_invoke_choicet (   self,
  a,
  choice = (u'a', u'b',
  u,
  c 
) [private]

Definition at line 724 of file test_wikiutil.py.

00724 
00725     def _test_invoke_choicet(self, a, choice=(u'a', u'b', u'c')):
00726         assert a == 7
00727         assert choice == u'a'

Here is the caller graph for this function:

Definition at line 714 of file test_wikiutil.py.

00714 
00715     def _test_invoke_float_None(self, i=float):
00716         assert i == 1.4 or i is None

Here is the caller graph for this function:

Definition at line 717 of file test_wikiutil.py.

00717 
00718     def _test_invoke_float_required(self, i=wikiutil.required_arg(float)):
00719         assert i == 1.4

Here is the caller graph for this function:

Definition at line 711 of file test_wikiutil.py.

00711 
00712     def _test_invoke_int_None(self, i=int):
00713         assert i == 1 or i is None

Here is the caller graph for this function:

def MoinMoin._tests.test_wikiutil.TestExtensionInvoking._test_trailing (   self,
  a,
  _trailing_args = [] 
) [private]

Definition at line 731 of file test_wikiutil.py.

00731 
00732     def _test_trailing(self, a, _trailing_args=[]):
00733         assert _trailing_args == [u'a']

Here is the caller graph for this function:

Definition at line 863 of file test_wikiutil.py.

00863 
00864     def testAllDefault(self):
00865         ief = wikiutil.invoke_extension_function
00866 
00867         def has_many_defaults(a=1, b=2, c=3, d=4):
00868             assert a == 1
00869             assert b == 2
00870             assert c == 3
00871             assert d == 4
00872             return True
00873 
00874         assert ief(self.request, has_many_defaults, u'1, 2, 3, 4')
00875         assert ief(self.request, has_many_defaults, u'2, 3, 4', [1])
00876         assert ief(self.request, has_many_defaults, u'3, 4', [1, 2])
00877         assert ief(self.request, has_many_defaults, u'4', [1, 2, 3])
00878         assert ief(self.request, has_many_defaults, u'', [1, 2, 3, 4])
00879         assert ief(self.request, has_many_defaults, u'd=4,c=3,b=2,a=1')
00880         assert ief(self.request, has_many_defaults, u'd=4,c=3,b=2', [1])
00881         assert ief(self.request, has_many_defaults, u'd=4,c=3', [1, 2])
00882         assert ief(self.request, has_many_defaults, u'd=4', [1, 2, 3])

Here is the call graph for this function:

Definition at line 813 of file test_wikiutil.py.

00813 
00814     def testConstructors(self):
00815         ief = wikiutil.invoke_extension_function
00816 
00817         # new style class
00818         class TEST1(object):
00819             def __init__(self, a=int):
00820                 self.constructed = True
00821                 assert a == 7
00822 
00823         class TEST2(TEST1):
00824             pass
00825 
00826         obj = ief(self.request, TEST1, u'a=7')
00827         assert isinstance(obj, TEST1)
00828         assert obj.constructed
00829         py.test.raises(ValueError, ief, self.request, TEST1, u'b')
00830 
00831         obj = ief(self.request, TEST2, u'a=7')
00832         assert isinstance(obj, TEST1)
00833         assert isinstance(obj, TEST2)
00834         assert obj.constructed
00835         py.test.raises(ValueError, ief, self.request, TEST2, u'b')
00836 
00837         # old style class
00838         class TEST3:
00839             def __init__(self, a=int):
00840                 self.constructed = True
00841                 assert a == 7
00842 
00843         class TEST4(TEST3):
00844             pass
00845 
00846         obj = ief(self.request, TEST3, u'a=7')
00847         assert isinstance(obj, TEST3)
00848         assert obj.constructed
00849         py.test.raises(ValueError, ief, self.request, TEST3, u'b')
00850 
00851         obj = ief(self.request, TEST4, u'a=7')
00852         assert isinstance(obj, TEST3)
00853         assert isinstance(obj, TEST4)
00854         assert obj.constructed
00855         py.test.raises(ValueError, ief, self.request, TEST4, u'b')

Definition at line 856 of file test_wikiutil.py.

00856 
00857     def testFailing(self):
00858         ief = wikiutil.invoke_extension_function
00859 
00860         py.test.raises(TypeError, ief, self.request, hex, u'15')
00861         py.test.raises(TypeError, ief, self.request, cmp, u'15')
00862         py.test.raises(AttributeError, ief, self.request, unicode, u'15')

Here is the call graph for this function:

Definition at line 737 of file test_wikiutil.py.

00737 
00738     def testInvoke(self):
00739         def _test_invoke_int(i=int):
00740             assert i == 1
00741 
00742         def _test_invoke_int_fixed(a, b, i=int):
00743             assert a == 7
00744             assert b == 8
00745             assert i == 1 or i is None
00746 
00747         ief = wikiutil.invoke_extension_function
00748         ief(self.request, self._test_invoke_bool, u'False')
00749         ief(self.request, self._test_invoke_bool, u'b=False')
00750         ief(self.request, _test_invoke_int, u'1')
00751         ief(self.request, _test_invoke_int, u'i=1')
00752         ief(self.request, self._test_invoke_bool_def, u'False, False')
00753         ief(self.request, self._test_invoke_bool_def, u'b=False, v=False')
00754         ief(self.request, self._test_invoke_bool_def, u'False')
00755         ief(self.request, self._test_invoke_int_None, u'i=1')
00756         ief(self.request, self._test_invoke_int_None, u'i=')
00757         ief(self.request, self._test_invoke_int_None, u'')
00758         py.test.raises(ValueError, ief, self.request,
00759                        self._test_invoke_int_None, u'x')
00760         py.test.raises(ValueError, ief, self.request,
00761                        self._test_invoke_int_None, u'""')
00762         py.test.raises(ValueError, ief, self.request,
00763                        self._test_invoke_int_None, u'i=""')
00764         py.test.raises(ValueError, ief, self.request,
00765                        _test_invoke_int_fixed, u'a=7', [7, 8])
00766         ief(self.request, _test_invoke_int_fixed, u'i=1', [7, 8])
00767         py.test.raises(ValueError, ief, self.request,
00768                        _test_invoke_int_fixed, u'i=""', [7, 8])
00769         ief(self.request, _test_invoke_int_fixed, u'i=', [7, 8])
00770 
00771         for choicefn in (self._test_invoke_choice, self._test_invoke_choicet):
00772             ief(self.request, choicefn, u'', [7])
00773             ief(self.request, choicefn, u'choice=a', [7])
00774             ief(self.request, choicefn, u'choice=', [7])
00775             ief(self.request, choicefn, u'choice="a"', [7])
00776             py.test.raises(ValueError, ief, self.request,
00777                            choicefn, u'x', [7])
00778             py.test.raises(ValueError, ief, self.request,
00779                            choicefn, u'choice=x', [7])
00780 
00781         ief(self.request, self._test_invoke_float_None, u'i=1.4')
00782         ief(self.request, self._test_invoke_float_None, u'i=')
00783         ief(self.request, self._test_invoke_float_None, u'')
00784         ief(self.request, self._test_invoke_float_None, u'1.4')
00785         py.test.raises(ValueError, ief, self.request,
00786                        self._test_invoke_float_None, u'x')
00787         py.test.raises(ValueError, ief, self.request,
00788                        self._test_invoke_float_None, u'""')
00789         py.test.raises(ValueError, ief, self.request,
00790                        self._test_invoke_float_None, u'i=""')
00791         ief(self.request, self._test_trailing, u'a=7, a')
00792         ief(self.request, self._test_trailing, u'7, a')
00793         ief(self.request, self._test_arbitrary_kw, u'test=x, \xc3=test',
00794             [{u'\xc3': 'test', 'test': u'x'}])
00795         ief(self.request, self._test_arbitrary_kw, u'test=x, "\xc3"=test',
00796             [{u'\xc3': 'test', 'test': u'x'}])
00797         ief(self.request, self._test_arbitrary_kw, u'test=x, "7 \xc3"=test',
00798             [{u'7 \xc3': 'test', 'test': u'x'}])
00799         ief(self.request, self._test_arbitrary_kw, u'test=x, 7 \xc3=test',
00800             [{u'7 \xc3': 'test', 'test': u'x'}])
00801         ief(self.request, self._test_arbitrary_kw, u'7 \xc3=test, test= x ',
00802             [{u'7 \xc3': 'test', 'test': u'x'}])
00803         py.test.raises(ValueError, ief, self.request,
00804                        self._test_invoke_float_required, u'')
00805         ief(self.request, self._test_invoke_float_required, u'1.4')
00806         ief(self.request, self._test_invoke_float_required, u'i=1.4')
00807         py.test.raises(ValueError, ief, self.request,
00808                        self._test_invoke_choice_required, u'')
00809         ief(self.request, self._test_invoke_choice_required, u'a')
00810         ief(self.request, self._test_invoke_choice_required, u'i=a')
00811         py.test.raises(ValueError, ief, self.request,
00812                        self._test_invoke_float_required, u',')

Here is the call graph for this function:

Definition at line 883 of file test_wikiutil.py.

00883 
00884     def testInvokeComplex(self):
00885         ief = wikiutil.invoke_extension_function
00886 
00887         def has_complex(a=complex, b=complex):
00888             assert a == b
00889             return True
00890 
00891         assert ief(self.request, has_complex, u'3-3i, 3-3j')
00892         assert ief(self.request, has_complex, u'2i, 2j')
00893         assert ief(self.request, has_complex, u'b=2i, a=2j')
00894         assert ief(self.request, has_complex, u'2.007, 2.007')
00895         assert ief(self.request, has_complex, u'2.007', [2.007])
00896         assert ief(self.request, has_complex, u'b=2.007', [2.007])
00897 

Here is the call graph for this function:


Member Data Documentation

Definition at line 819 of file test_wikiutil.py.


The documentation for this class was generated from the following file: