From 79cb1c0d3048c165fd3b9ff287ee1fbe361f904d Mon Sep 17 00:00:00 2001 From: Eevee Date: Sun, 10 Jan 2010 01:26:09 -0800 Subject: [PATCH] Test suite runs and passes! - Fixed some uses of UserRelation, which is now called UserRelationship. - Fixed link generation on the users list. - Removed some of the shabti cruft from the main test setup script. The test suite now creates the entire database once at the very beginning, then drops everything at the very end. - Stubber-ed out various stub controller tests that assumed an 'index' action which no longer exists. - Changed the shabti test that assumes / contains a mention of Elixir. - Removed the shabti tests which defined some bogus tables and then tried to use them, for reasons I cannot fathom. --- floof/controllers/relation.py | 6 ++-- floof/templates/users/index.mako | 3 +- floof/tests/__init__.py | 41 ++++++++++++---------------- floof/tests/functional/test_account.py | 4 +-- floof/tests/functional/test_appserver.py | 2 +- floof/tests/functional/test_art.py | 4 +-- floof/tests/functional/test_comments.py | 8 ++++-- floof/tests/functional/test_gallery.py | 6 ++-- floof/tests/functional/test_tag.py | 6 ++-- floof/tests/functional/test_user_settings.py | 6 ++-- floof/tests/functional/test_users.py | 4 +-- floof/tests/test_models.py | 14 +++++----- test.ini | 2 +- 13 files changed, 55 insertions(+), 51 deletions(-) diff --git a/floof/controllers/relation.py b/floof/controllers/relation.py index 719fe2b..330559e 100644 --- a/floof/controllers/relation.py +++ b/floof/controllers/relation.py @@ -8,7 +8,7 @@ from floof.lib.base import BaseController, render log = logging.getLogger(__name__) -from floof.model import Art, UserRelation +from floof.model import Art, UserRelationship from floof.model.users import User import elixir @@ -21,11 +21,11 @@ class RelationController(BaseController): user = h.get_object_or_404(User, name=request.params['username']) ## TODO: actually, this should act like a form validation. - prior_relation = UserRelation.get_by(art=art, user=user) + prior_relation = UserRelationship.get_by(art=art, user=user) if prior_relation: abort(404) ## should be a validation error - relation = UserRelation(user=user, kind=kind, art=art, creator=c.user) + relation = UserRelationship(user=user, kind=kind, art=art, creator=c.user) elixir.session.commit() redirect(url('show_art', id=art_id)) diff --git a/floof/templates/users/index.mako b/floof/templates/users/index.mako index b16bbaf..fc83ae9 100644 --- a/floof/templates/users/index.mako +++ b/floof/templates/users/index.mako @@ -2,7 +2,6 @@ diff --git a/floof/tests/__init__.py b/floof/tests/__init__.py index fc14a48..f7621ed 100644 --- a/floof/tests/__init__.py +++ b/floof/tests/__init__.py @@ -41,45 +41,40 @@ conf = appconfig('config:' + test_file) load_environment(conf.global_conf, conf.local_conf) environ = {} -engine = engine_from_config(config, 'sqlalchemy.') -model.init_model(engine) -metadata = elixir.metadata -Session = elixir.session = meta.Session +engine = elixir.metadata.bind -class Individual(Entity): - """Table 'Individual'. - - >>> me = Individual('Groucho') - - # 'name' field is converted to lowercase - >>> me.name - 'groucho' - """ - name = Field(String(20), unique=True) - favorite_color = Field(String(20)) - - def __init__(self, name, favorite_color=None): - self.name = str(name).lower() - self.favorite_color = favorite_color - -setup_all() def setup(): + """Setup for the entire test suite.""" + setup_all(create_tables=True) pass def teardown(): + """Teardown for the entire test suite.""" + drop_all(engine) pass + class TestModel(TestCase): def setUp(self): - setup_all(True) + pass def tearDown(self): - drop_all(engine) + pass class TestController(TestCase): + def setUp(self): + """Setup for a controller test class. + """ + pass + + def tearDown(self): + """Teardown for a controller test class. + """ + pass + def __init__(self, *args, **kwargs): if pylons.test.pylonsapp: wsgiapp = pylons.test.pylonsapp diff --git a/floof/tests/functional/test_account.py b/floof/tests/functional/test_account.py index 27eb4c3..b7f46e6 100644 --- a/floof/tests/functional/test_account.py +++ b/floof/tests/functional/test_account.py @@ -2,6 +2,6 @@ from floof.tests import * class TestAccountController(TestController): - def test_index(self): - response = self.app.get(url(controller='account', action='index')) + def test_login(self): + response = self.app.get(url(controller='account', action='login')) # Test response... diff --git a/floof/tests/functional/test_appserver.py b/floof/tests/functional/test_appserver.py index 03ce23a..d770839 100644 --- a/floof/tests/functional/test_appserver.py +++ b/floof/tests/functional/test_appserver.py @@ -4,4 +4,4 @@ class TestAppServer(TestController): def test_index(self): response = self.app.get('/') # Test response... - assert 'Elixir DSL' in response + assert 'Powered by floof' in response diff --git a/floof/tests/functional/test_art.py b/floof/tests/functional/test_art.py index e82d5c8..404b08e 100644 --- a/floof/tests/functional/test_art.py +++ b/floof/tests/functional/test_art.py @@ -2,6 +2,6 @@ from floof.tests import * class TestArtController(TestController): - def test_index(self): - response = self.app.get(url(controller='art', action='index')) + def test_upload(self): + response = self.app.get(url(controller='art', action='new')) # Test response... diff --git a/floof/tests/functional/test_comments.py b/floof/tests/functional/test_comments.py index 908d1bc..8bebe13 100644 --- a/floof/tests/functional/test_comments.py +++ b/floof/tests/functional/test_comments.py @@ -2,6 +2,10 @@ from floof.tests import * class TestCommentsController(TestController): - def test_index(self): - response = self.app.get(url(controller='comments', action='index')) + def test_nothing(self): + # Can't stub out testing comments. Need to actually + # post one for anything in the controller to make + # sense. + pass + #response = self.app.get(url(controller='comments', action='index')) # Test response... diff --git a/floof/tests/functional/test_gallery.py b/floof/tests/functional/test_gallery.py index 695513c..3a25d01 100644 --- a/floof/tests/functional/test_gallery.py +++ b/floof/tests/functional/test_gallery.py @@ -2,6 +2,8 @@ from floof.tests import * class TestGalleryController(TestController): - def test_index(self): - response = self.app.get(url(controller='gallery', action='index')) + def test_nothing(self): + # Main gallery browse page doesn't exist yet. + pass + #response = self.app.get(url(controller='gallery', action='index')) # Test response... diff --git a/floof/tests/functional/test_tag.py b/floof/tests/functional/test_tag.py index 8424b43..6d014f7 100644 --- a/floof/tests/functional/test_tag.py +++ b/floof/tests/functional/test_tag.py @@ -2,6 +2,8 @@ from floof.tests import * class TestTagController(TestController): - def test_index(self): - response = self.app.get(url(controller='tag', action='index')) + def test_nothing(self): + # Tag controller only does things. Doesn't show things yet. + pass + #response = self.app.get(url(controller='tag', action='index')) # Test response... diff --git a/floof/tests/functional/test_user_settings.py b/floof/tests/functional/test_user_settings.py index b28f8be..bb61a03 100644 --- a/floof/tests/functional/test_user_settings.py +++ b/floof/tests/functional/test_user_settings.py @@ -2,6 +2,8 @@ from floof.tests import * class TestUserSettingsController(TestController): - def test_index(self): - response = self.app.get(url(controller='user_settings', action='index')) + def test_nothing(self): + # Only does things. Doesn't have an index. + pass + #response = self.app.get(url(controller='user_settings', action='index')) # Test response... diff --git a/floof/tests/functional/test_users.py b/floof/tests/functional/test_users.py index cc1aeb1..2bd1539 100644 --- a/floof/tests/functional/test_users.py +++ b/floof/tests/functional/test_users.py @@ -2,6 +2,6 @@ from floof.tests import * class TestUsersController(TestController): - def test_index(self): - response = self.app.get(url(controller='users', action='index')) + def test_list(self): + response = self.app.get(url(controller='users', action='list')) # Test response... diff --git a/floof/tests/test_models.py b/floof/tests/test_models.py index 9b27a5c..ccd2a41 100644 --- a/floof/tests/test_models.py +++ b/floof/tests/test_models.py @@ -1,22 +1,22 @@ from sqlalchemy.exceptions import IntegrityError +from floof.model import User +from floof.model.meta import Session from floof.tests import * -from floof.tests import Session, metadata, Individual, create_all, drop_all class TestMyModel(TestModel): def test_simpleassert(self): """test description """ - einstein = Individual('einstein') - + einstein = User(name=u'einstein', display_name=u'Einstein') Session.commit() - ind1 = Individual.get_by(name = 'einstein') - assert ind1 == einstein + user1 = User.get_by(name = u'einstein') + assert user1 == einstein def test_exception(self): - me = Individual('giuseppe') - me_again = Individual('giuseppe') + me = User(name=u'giuseppe', display_name=u'giuseppe') + me_again = User(name=u'giuseppe', display_name=u'giuseppe') self.assertRaises(IntegrityError, Session.commit) Session.rollback() diff --git a/test.ini b/test.ini index a16fbdc..bf1dca3 100644 --- a/test.ini +++ b/test.ini @@ -20,4 +20,4 @@ use = config:development.ini # Add additional test specific configuration options as necessary. sqlalchemy.url = sqlite:///%(here)s/nosetest.db -sqlalchemy.echo = False \ No newline at end of file +sqlalchemy.echo = False -- 2.7.4