changeset 722:cbc2976d018b pytest2

get the items from xml in the test itself rather than in app.import_export_xml, removed import_export_xml from create_app_ext; tests become faster
author pkumar <contactprashantat@gmail.com>
date Mon, 08 Aug 2011 18:08:33 +0530
parents 33475ee387b3
children d2099fe6b0fe
files MoinMoin/_tests/test_test_environ.py MoinMoin/_tests/test_wikiutil.py MoinMoin/app.py MoinMoin/auth/_tests/test_http.py
diffstat 4 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_test_environ.py	Mon Aug 08 13:49:58 2011 +0530
+++ b/MoinMoin/_tests/test_test_environ.py	Mon Aug 08 18:08:33 2011 +0530
@@ -14,6 +14,7 @@
 from MoinMoin.conftest import init_test_app, deinit_test_app
 from MoinMoin.config import NAME, CONTENTTYPE, IS_SYSITEM, SYSITEM_VERSION
 from MoinMoin.storage.error import NoSuchItemError
+from MoinMoin.storage.serialization import serialize, unserialize
 
 from MoinMoin._tests import wikiconfig
 
@@ -46,6 +47,7 @@
     # Run this test twice to see if something's changed
     test_twice = test_fresh_backends
 
+
 class TestStorageEnvironWithConfig(object):
     class Config(wikiconfig.Config):
         load_xml = wikiconfig.Config._test_items_xml
@@ -57,6 +59,10 @@
         )
 
     def test_fresh_backends_with_content(self):
+        # get the items from xml file
+        backend = app.unprotected_storage
+        unserialize(backend, self.Config.load_xml)
+
         assert isinstance(app.cfg, wikiconfig.Config)
 
         storage = flaskg.storage
@@ -72,7 +78,7 @@
             new_rev = item.create_revision(1)
             new_rev[NAME] = pagename
             new_rev[CONTENTTYPE] = u'text/plain'
-            item.commit()
+            #item.commit()
 
         itemname = u"OnlyForThisTest"
         assert not storage.has_item(itemname)
--- a/MoinMoin/_tests/test_wikiutil.py	Mon Aug 08 13:49:58 2011 +0530
+++ b/MoinMoin/_tests/test_wikiutil.py	Mon Aug 08 18:08:33 2011 +0530
@@ -13,6 +13,7 @@
 
 from MoinMoin import config, wikiutil
 from MoinMoin._tests import wikiconfig
+from MoinMoin.storage.serialization import serialize, unserialize
 
 from werkzeug import MultiDict
 
@@ -42,6 +43,10 @@
 
     def testSystemItem(self):
         """wikiutil: good system item names accepted, bad rejected"""
+        # get the items from xml file
+        backend = app.unprotected_storage
+        unserialize(backend, self.Config.load_xml)
+
         for name in self.systemItems:
             assert wikiutil.isSystemItem(name)
         for name in self.notSystemItems:
--- a/MoinMoin/app.py	Mon Aug 08 13:49:58 2011 +0530
+++ b/MoinMoin/app.py	Mon Aug 08 18:08:33 2011 +0530
@@ -138,7 +138,6 @@
         app.unprotected_storage.index_rebuild() # XXX run this from a script
     clock.stop('create_app index rebuild')
     clock.start('create_app load/save xml')
-    import_export_xml(app)
     clock.stop('create_app load/save xml')
     clock.start('create_app flask-babel')
     i18n_init(app)
--- a/MoinMoin/auth/_tests/test_http.py	Mon Aug 08 13:49:58 2011 +0530
+++ b/MoinMoin/auth/_tests/test_http.py	Mon Aug 08 18:08:33 2011 +0530
@@ -12,7 +12,7 @@
 from MoinMoin.auth.http import HTTPAuthMoin
 import pytest
 
-class TestHTTPAuthMoin(object): 
+class TestHTTPAuthMoin(object):
     """ Test: HTTPAuthMoin """
     class Auth:
         def __init__(self):