Show
Ignore:
Timestamp:
07/10/08 13:37:49 (2 years ago)
Author:
JensDiemer
Message:

Fix for ticket:202 - kwargs in template tag {% lucidTag ... %}
Discuss in:  http://pylucid.org/phpBB2/viewtopic.php?t=228

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/tests/test_plugin_api.py

    r1646 r1666  
    204204        # plugin model tables should be re-created, too. 
    205205        install_plugin( 
    206             package_name, plugin_name, page_msg, verbosity=2, active=True 
     206            package_name, plugin_name, 
     207            page_msg, verbosity=2, user=None, active=True 
    207208        ) 
    208209 
     
    281282        ) 
    282283        self.assertEqual2(args, "()") 
    283         self.assertEqual2(kwargs, "{'arg1': u'test1'}") 
    284  
    285     def test_tag_more_args(self): 
    286         """ 
    287         More string kwargs 
     284        self.assertEqual2(kwargs, "{'arg1': 'test1'}") 
     285 
     286    def test_numbers(self): 
     287        """ 
     288        Test string and numbers 
    288289        """ 
    289290        args, kwargs = self._get_args_info( 
    290             '{% lucidTag unittest_plugin a="0" b="1" c="2" %}' 
     291            '{% lucidTag unittest_plugin a="0" b=1 c=2 %}' 
    291292        ) 
    292293        self.assertEqual2(args, "()") 
    293         self.assertEqual2(kwargs, "{'a': u'0', 'b': u'1', 'c': u'2'}") 
    294  
    295     def test_tag_bool_args1(self): 
    296         """ 
    297         The current implementation converts strings to bool if it found 
    298         the bool words. 
     294        self.assertEqual2(kwargs, "{'a': 0, 'b': 1, 'c': 2}") 
     295 
     296    def test_keywords(self): 
     297        """ 
     298        Test True, False and None 
    299299        """ 
    300300        args, kwargs = self._get_args_info( 
    301             '{% lucidTag unittest_plugin' 
    302             ' t1="True" f1="False" t2="true" f2="false" %}' 
     301            '{% lucidTag unittest_plugin a=True b=False c=None %}' 
    303302        ) 
    304303        self.assertEqual2(args, "()") 
    305304        self.assertEqual2(kwargs, 
    306             "{'f1': False, 'f2': False, 't1': True, 't2': True}" 
    307         ) 
    308  
    309     #__________________________________________________________________________ 
    310     # Problems with the current implementation. 
    311     # We can't pass other things than string. 
    312     """ 
    313     Importtant: All follow test will failed! 
    314     See: 
    315         http://pylucid.net:8080/pylucid/ticket/202 
    316         http://pylucid.org/phpBB2/viewtopic.php?t=228 
    317     """ 
    318     def test_tag_bool_args2(self): 
    319         """ 
    320         Faild in the current implementation! 
    321         """ 
    322         args, kwargs = self._get_args_info( 
    323             '{% lucidTag unittest_plugin t1=True f1=False %}' 
    324         ) 
    325         self.assertEqual2(args, "()") 
    326         self.assertEqual2(kwargs, 
    327             "{'f1': False, 'f2': False}", 
    328             error_msg="Faild in the current implementation!" 
    329         ) 
    330  
    331     def test_non_string_args(self): 
    332         """ 
    333         Faild in the current implementation! 
    334         """ 
    335         args, kwargs = self._get_args_info( 
    336             '{% lucidTag unittest_plugin arg1=1 arg2=2.0 %}' 
    337         ) 
    338         self.assertEqual2(args, "()") 
    339         self.assertEqual2(kwargs, 
    340             "{'arg1': 1, 'args2': 2.0}", 
    341             error_msg="Faild in the current implementation!" 
    342         ) 
    343  
    344  
    345  
     305            "{'a': True, 'b': False, 'c': None}" 
     306        ) 
     307 
     308 
     309class PluginPreferencesTest(PluginAPI_Base): 
     310    """ 
     311    Test the preferences API. 
     312 
     313    more info about plugin preferences: 
     314        http://www.pylucid.org/_goto/153/preferences/ 
     315    """ 
     316    def test(self): 
     317        url = self.command % "test_preferences" 
     318        content = self._get_plugin_content(url, debug=False) 
     319        self.assertEqual2( 
     320            content, 
     321            "{'index': u'Index', 'print_index': False, 'print_last_page': True," 
     322            " 'index_url': u'/'}" 
     323        ) 
    346324 
    347325