Package eggbasket :: Package tests :: Module test_model
[hide private]

Source Code for Module eggbasket.tests.test_model

 1  """Unit test cases for testing you application's model classes. 
 2   
 3  If your project uses a database, you should set up database tests similar to 
 4  what you see below. 
 5   
 6  Be sure to set the ``db_uri`` in the ``test.cfg`` configuration file in the 
 7  top-level directory of your project to an appropriate uri for your testing 
 8  database. SQLite is a good choice for testing, because you can use an in-memory 
 9  database which is very fast and the data in it has to be boot-strapped from 
10  scratch every time, so the tests are independant of any pre-existing data. 
11   
12  You can also set the ``db_uri``directly in this test file but then be sure 
13  to do this before you import your model, e.g.:: 
14   
15      from turbogears import testutil, database 
16      database.set_db_uri("sqlite:///:memory:") 
17      from eggbasket.model import YourModelClass, User, ... 
18  """ 
19   
20  from turbogears import testutil, database 
21   
22  # from eggbasket.model import YourModelClass, User 
23   
24  # class TestUser(testutil.DBTest): 
25  #     def get_model(self): 
26  #         return User 
27  #     def test_creation(self): 
28  #         """Object creation should set the name.""" 
29  #         obj = User(user_name = "creosote", 
30  #                 email_address = "spam@python.not", 
31  #                 display_name = "Mr Creosote", 
32  #                 password = "Wafer-thin Mint") 
33  #         assert obj.display_name == "Mr Creosote" 
34