Skip to content

Commit

Permalink
added initial models for courses
Browse files Browse the repository at this point in the history
  • Loading branch information
brunosmartin committed Jul 18, 2013
1 parent fbede98 commit 6fe0cb4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setup():
engine = create_engine('sqlite://')
from timtec.models import (
Base,
User
User,
)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
Expand All @@ -37,9 +37,29 @@ def test_it():
assert info['one'].username == 'one'
assert info['project'] == 'timtec'


def test_app_creation():
from paste.deploy.loadwsgi import appconfig
from timtec import main
settings = appconfig('config:' + resource_filename(__name__, '../development.ini'))
app = main(config, **settings)
assert isinstance(app, router.Router)


def test_course():
from timtec.models import Course
course = Course(name='Nome', description='desc')
assert course.name == 'Nome'
assert course.description == 'desc'


def test_course_class():
from timtec.models import CourseClass
course_class = CourseClass(name='Nome')
assert course_class.name == 'Nome'


def test_video():
from timtec.models import Video
video = Video(name='Nome')
assert video.name == 'Nome'
24 changes: 24 additions & 0 deletions timtec/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ActivationMixin,
)


class BaseModel(object):
"""Base class which auto-generates tablename, and surrogate
primary key column.
Expand Down Expand Up @@ -47,6 +48,7 @@ def __tablename__(cls):
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base(cls=BaseModel)


class User(UserMixin, Base):
pass

Expand All @@ -61,3 +63,25 @@ class UserGroup(UserGroupMixin, Base):

class Activation(ActivationMixin, Base):
pass


class Video(Base):
name = sa.Column(sa.Unicode(255), nullable=False)


class Course(Base):
"""Course """
name = sa.Column(sa.Unicode(255), nullable=False)
description = sa.Column(sa.Text(255))
knowledge_acquired = sa.Column(sa.Text(255))
knowledge_required = sa.Column(sa.Text(255))
professors = sa.Column(sa.Integer, sa.ForeignKey("{0}.pk".format(User.__tablename__)))
intro_video = sa.Column(sa.Integer, sa.ForeignKey("{0}.pk".format(Video.__tablename__)))
students = sa.Column(sa.Integer, sa.ForeignKey("{0}.pk".format(User.__tablename__)))
# wiki
# forum
# notes


class CourseClass(Base):
name = sa.Column(sa.Unicode(255), nullable=False)

0 comments on commit 6fe0cb4

Please sign in to comment.