accounts2/fas/fas/tests __init__.py, NONE, 1.1 test_controllers.py, NONE, 1.1 test_model.py, NONE, 1.1

Michael Patrick McGrath (mmcgrath) fedora-extras-commits at redhat.com
Mon Mar 26 15:11:26 UTC 2007


Author: mmcgrath

Update of /cvs/fedora/accounts2/fas/fas/tests
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26831/fas/fas/tests

Added Files:
	__init__.py test_controllers.py test_model.py 
Log Message:
added tg fas2 code


--- NEW FILE __init__.py ---


--- NEW FILE test_controllers.py ---
import turbogears
from nose import with_setup
from turbogears import testutil
from fas.controllers import Root
import cherrypy

def teardown_func():
    """Tests for apps using identity need to stop CP/TG after each test to
    stop the VisitManager thread. See http://trac.turbogears.org/turbogears/ticket/1217
    for details.
    """
    turbogears.startup.stopTurboGears()

cherrypy.root = Root()

def test_method():
    "the index method should return a string called now"
    import types
    result = testutil.call(cherrypy.root.index)
    assert type(result["now"]) == types.StringType
test_method = with_setup(teardown=teardown_func)(test_method)

def test_indextitle():
    "The indexpage should have the right title"
    testutil.createRequest("/")
    assert "<TITLE>Welcome to TurboGears</TITLE>" in cherrypy.response.body[0]
test_indextitle = with_setup(teardown=teardown_func)(test_indextitle)

def test_logintitle():
    "login page should have the right title"
    testutil.createRequest("/login")
    assert "<TITLE>Login</TITLE>" in cherrypy.response.body[0]
test_logintitle = with_setup(teardown=teardown_func)(test_logintitle)


--- NEW FILE test_model.py ---
# If your project uses a database, you can set up database tests
# similar to what you see below. Be sure to set the db_uri to
# an appropriate uri for your testing database. sqlite is a good
# choice for testing, because you can use an in-memory database
# which is very fast.

from turbogears import testutil, database
# from fas.model import YourDataClass, User

# database.set_db_uri("sqlite:///:memory:")

# class TestUser(testutil.DBTest):
#     def get_model(self):
#         return User
#     def test_creation(self):
#         "Object creation should set the name"
#         obj = User(user_name = "creosote",
#                       email_address = "spam at python.not",
#                       display_name = "Mr Creosote",
#                       password = "Wafer-thin Mint")
#         assert obj.display_name == "Mr Creosote"





More information about the fedora-extras-commits mailing list