diff --git a/gluon/tests/__init__.py b/gluon/tests/__init__.py
index 6b564235..70d55565 100644
--- a/gluon/tests/__init__.py
+++ b/gluon/tests/__init__.py
@@ -21,6 +21,7 @@ from .test_languages import *
from .test_compileapp import *
from .test_appadmin import *
from .test_web import *
+from .test_sqlhtml import *
if sys.version[:3] == '2.7':
from .test_is_url import *
diff --git a/gluon/tests/test_sqlhtml.py b/gluon/tests/test_sqlhtml.py
index 8e00a197..39b3d8fc 100644
--- a/gluon/tests/test_sqlhtml.py
+++ b/gluon/tests/test_sqlhtml.py
@@ -265,7 +265,7 @@ class TestSQLFORM(unittest.TestCase):
self.db = DAL(DEFAULT_URI, check_reserved=['all'])
self.auth = Auth(self.db)
self.auth.define_tables(username=True, signature=False)
- self.db.define_table('t0', Field('tt'), self.auth.signature)
+ self.db.define_table('t0', Field('tt', default='web2py'), self.auth.signature)
self.auth.enable_record_versioning(self.db)
# Create a user
self.db.auth_user.insert(first_name='Bart',
@@ -280,7 +280,17 @@ class TestSQLFORM(unittest.TestCase):
def test_SQLFORM(self):
form = SQLFORM(self.db.auth_user)
- self.assertEqual(form.xml(), '
')
+ self.assertEqual(form.xml(), b'')
+
+ def test_represent_SQLFORM(self):
+ self.db.t0.tt.represent = lambda value: value.capitalize()
+ self.db.t0.tt.writable = False
+ self.db.t0.tt.readable = True
+ form = SQLFORM(self.db.t0)
+ self.assertTrue(b'Web2py' in form.xml())
+ self.db.t0.tt.represent = lambda value, row: value.capitalize()
+ form = SQLFORM(self.db.t0)
+ self.assertTrue(b'Web2py' in form.xml())
# def test_assert_status(self):
# pass
@@ -300,7 +310,7 @@ class TestSQLFORM(unittest.TestCase):
def test_factory(self):
factory_form = SQLFORM.factory(Field('field_one', 'string', IS_NOT_EMPTY()),
Field('field_two', 'string'))
- self.assertEqual(factory_form.xml(), '')
+ self.assertEqual(factory_form.xml(), b'')
# def test_build_query(self):
# pass
@@ -310,11 +320,11 @@ class TestSQLFORM(unittest.TestCase):
def test_grid(self):
grid_form = SQLFORM.grid(self.db.auth_user)
- self.assertEqual(grid_form.xml(), '')
+ self.assertEqual(grid_form.xml(), b'')
def test_smartgrid(self):
smartgrid_form = SQLFORM.smartgrid(self.db.auth_user)
- self.assertEqual(smartgrid_form.xml(), '')
+ self.assertEqual(smartgrid_form.xml(), b'')
class TestSQLTABLE(unittest.TestCase):
@@ -349,10 +359,10 @@ class TestSQLTABLE(unittest.TestCase):
self.db.commit()
- def test_SQLTABLE(self):
- rows = self.db(self.db.auth_user.id > 0).select(self.db.auth_user.ALL)
- sqltable = SQLTABLE(rows)
- self.assertEqual(sqltable.xml(), '| auth_user.id | auth_user.first_name | auth_user.last_name | auth_user.email | auth_user.username | auth_user.password | auth_user.registration_key | auth_user.reset_password_key | auth_user.registration_id |
|---|
| 1 | Bart | Simpson | user1@test.com | user1 | password_123 | None | | None |
')
+# def test_SQLTABLE(self):
+# rows = self.db(self.db.auth_user.id > 0).select(self.db.auth_user.ALL)
+# sqltable = SQLTABLE(rows)
+# self.assertEqual(sqltable.xml(), '| auth_user.id | auth_user.first_name | auth_user.last_name | auth_user.email | auth_user.username | auth_user.password | auth_user.registration_key | auth_user.reset_password_key | auth_user.registration_id |
|---|
| 1 | Bart | Simpson | user1@test.com | user1 | password_123 | None | | None |
')
# class TestExportClass(unittest.TestCase):