changeset 614:b016b5b3c0e2 pytest2

added test for wikiutil.is_URL in _tests/test_wikiutil
author pkumar <contactprashantat@gmail.com>
date Sun, 03 Jul 2011 22:55:35 +0530
parents cdfb5c99b774
children 6b173390b0e8
files MoinMoin/_tests/test_wikiutil.py MoinMoin/wikiutil.py
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Sun Jul 03 18:12:04 2011 +0530
+++ b/MoinMoin/_tests/test_wikiutil.py	Sun Jul 03 22:55:35 2011 +0530
@@ -203,6 +203,18 @@
     with pytest.raises(IndexError):
         result = wikiutil.getUnicodeIndexGroup('')
         
+def testis_URL():
+    sample_schemas = ['http', 'https', 'ftp', 'ssh']
+    for schema in sample_schemas:
+        result = wikiutil.is_URL(schema + ':MoinMoin')
+        assert result
+
+    # arg without ':' which is a mandatory requirement   
+    result = wikiutil.is_URL('MoinMoin')
+    assert result == False
+    # invalid schema
+    result = wikiutil.is_URL('invalid_schema:MoinMoin')
+    assert result == False
     
 coverage_modules = ['MoinMoin.wikiutil']
 
--- a/MoinMoin/wikiutil.py	Sun Jul 03 18:12:04 2011 +0530
+++ b/MoinMoin/wikiutil.py	Sun Jul 03 22:55:35 2011 +0530
@@ -252,6 +252,8 @@
     """
     if ':' not in arg:
         return False
+    #import pytest
+    #pytest.set_trace()
     for schema in schemas:
         if arg.startswith(schema + ':'):
             return True