- 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.
13 files changed:
log = logging.getLogger(__name__)
log = logging.getLogger(__name__)
-from floof.model import Art, UserRelation
+from floof.model import Art, UserRelationship
from floof.model.users import User
import elixir
from floof.model.users import User
import elixir
user = h.get_object_or_404(User, name=request.params['username'])
## TODO: actually, this should act like a form validation.
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
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))
elixir.session.commit()
redirect(url('show_art', id=art_id))
<ul>
% for user in c.users:
<ul>
% for user in c.users:
-## TODO normalize URL names better perhaps
- <li><a href="${url.current(action='view', name=user.name.lower())}">${user.name}</a></li>
+ <li><a href="${url(controller='users', action='view', name=user.name.lower())}">${user.name}</a></li>
load_environment(conf.global_conf, conf.local_conf)
environ = {}
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()
+ """Setup for the entire test suite."""
+ setup_all(create_tables=True)
+ """Teardown for the entire test suite."""
+ drop_all(engine)
class TestModel(TestCase):
def setUp(self):
class TestModel(TestCase):
def setUp(self):
class TestController(TestCase):
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
def __init__(self, *args, **kwargs):
if pylons.test.pylonsapp:
wsgiapp = pylons.test.pylonsapp
class TestAccountController(TestController):
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'))
def test_index(self):
response = self.app.get('/')
# Test response...
def test_index(self):
response = self.app.get('/')
# Test response...
- assert '<span style="color:lime">Elixir DSL</span>' in response
+ assert 'Powered by floof' in response
class TestArtController(TestController):
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'))
class TestCommentsController(TestController):
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'))
class TestGalleryController(TestController):
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'))
class TestTagController(TestController):
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'))
class TestUserSettingsController(TestController):
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'))
class TestUsersController(TestController):
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'))
from sqlalchemy.exceptions import IntegrityError
from sqlalchemy.exceptions import IntegrityError
+from floof.model import User
+from floof.model.meta import Session
from floof.tests import *
from floof.tests import *
-from floof.tests import Session, metadata, Individual, create_all, drop_all
class TestMyModel(TestModel):
def test_simpleassert(self):
"""test description
"""
class TestMyModel(TestModel):
def test_simpleassert(self):
"""test description
"""
- einstein = Individual('einstein')
-
+ einstein = User(name=u'einstein', display_name=u'Einstein')
- ind1 = Individual.get_by(name = 'einstein')
- assert ind1 == einstein
+ user1 = User.get_by(name = u'einstein')
+ assert user1 == einstein
def test_exception(self):
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()
self.assertRaises(IntegrityError, Session.commit)
Session.rollback()
# Add additional test specific configuration options as necessary.
sqlalchemy.url = sqlite:///%(here)s/nosetest.db
# Add additional test specific configuration options as necessary.
sqlalchemy.url = sqlite:///%(here)s/nosetest.db
-sqlalchemy.echo = False
\ No newline at end of file