PY3 fixes and added tests for gluon/admin.py
This commit is contained in:
@@ -10,8 +10,12 @@ fix_sys_path(__file__)
|
||||
|
||||
from gluon.compileapp import compile_application, remove_compiled_application
|
||||
from gluon.fileutils import w2p_pack, w2p_unpack
|
||||
import os
|
||||
from gluon.globals import Request
|
||||
from gluon.admin import app_compile, app_create, app_cleanup, check_new_version, app_uninstall
|
||||
from gluon.main import global_settings
|
||||
import os, shutil
|
||||
|
||||
WEB2PY_VERSION_URL = "http://web2py.com/examples/default/version"
|
||||
|
||||
class TestPack(unittest.TestCase):
|
||||
""" Tests the compileapp.py module """
|
||||
@@ -30,6 +34,27 @@ class TestPack(unittest.TestCase):
|
||||
w2p_unpack(test_path, unpack_path)
|
||||
return
|
||||
|
||||
def test_admin_compile(self):
|
||||
#apps = ['welcome', 'admin', 'examples']
|
||||
request = Request(env={})
|
||||
request.application = 'a'
|
||||
request.controller = 'c'
|
||||
request.function = 'f'
|
||||
request.folder = 'applications/admin'
|
||||
apps = ['welcome']
|
||||
for appname in apps:
|
||||
appname_path = os.path.join(os.getcwd(), 'applications', appname)
|
||||
self.assertEqual(app_compile(appname_path, request), None)
|
||||
# remove any existing test_app
|
||||
new_app = 'test_app_%s' % (appname)
|
||||
if(os.path.exists('applications/%s' % (new_app))):
|
||||
shutil.rmtree('applications/%s' % (new_app))
|
||||
self.assertEqual(app_create(new_app, request), True)
|
||||
self.assertEqual(os.path.exists('applications/test_app_%s/controllers/default.py' % (appname)), True)
|
||||
self.assertEqual(app_cleanup(new_app, request), True)
|
||||
self.assertEqual(app_uninstall(new_app, request), True)
|
||||
self.assertNotEqual(check_new_version(global_settings.web2py_version, WEB2PY_VERSION_URL), -1)
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user