This commit was just to fix a few of the errors with the merging and to
authortilly-Q <nattilypigeonfowl@gmail.com>
Tue, 20 Aug 2013 19:11:02 +0000 (15:11 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Tue, 20 Aug 2013 19:24:29 +0000 (15:24 -0400)
make sure that all of the previous tests work fine.

mediagoblin/auth/tools.py
mediagoblin/db/migrations.py
mediagoblin/db/models.py
mediagoblin/tests/test_auth.py
mediagoblin/tests/test_edit.py
mediagoblin/tests/test_notifications.py
mediagoblin/tests/test_submission.py
mediagoblin/tests/tools.py

index 596a44478c453629142a4fb2372c88e2017a3d45..f758bca40b3b2edf06341b9424cd7905261cb504 100644 (file)
@@ -21,7 +21,7 @@ from sqlalchemy import or_
 
 from mediagoblin import mg_globals
 from mediagoblin.tools.crypto import get_timed_signer_url
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, Privilege
 from mediagoblin.tools.mail import (normalize_email, send_email,
                                     email_debug_message)
 from mediagoblin.tools.template import render_template
index 0eedc5d407bc05dd41c14f6c7e560375fcb5e7eb..762d17e6b50feedd9472aa48665c2c383b6eb0a8 100644 (file)
@@ -383,79 +383,6 @@ def pw_hash_nullable(db):
         constraint = UniqueConstraint('username', table=user_table)
         constraint.create()
 
-class ReportBase_v0(declarative_base()):
-    __tablename__ = 'core__reports'
-    id = Column(Integer, primary_key=True)
-    reporter_id = Column(Integer, ForeignKey(User.id), nullable=False)
-    report_content = Column(UnicodeText)
-    reported_user_id = Column(Integer, ForeignKey(User.id), nullable=False)
-    created = Column(DateTime, nullable=False, default=datetime.datetime.now) 
-    discriminator = Column('type', Unicode(50))
-    __mapper_args__ = {'polymorphic_on': discriminator}
-
-class CommentReport_v0(ReportBase_v0):
-    __tablename__ = 'core__reports_on_comments'
-    __mapper_args__ = {'polymorphic_identity': 'comment_report'}
-
-    id = Column('id',Integer, ForeignKey('core__reports.id'),
-                                                primary_key=True)
-    comment_id = Column(Integer, ForeignKey(MediaComment.id), nullable=False)
-
-class MediaReport_v0(ReportBase_v0):
-    __tablename__ = 'core__reports_on_media'
-    __mapper_args__ = {'polymorphic_identity': 'media_report'}
-
-    id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
-    media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=False)
-
-class ArchivedReport_v0(ReportBase_v0):
-    __tablename__ = 'core__reports_archived'
-    __mapper_args__ = {'polymorphic_identity': 'archived_report'}
-
-    id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
-    media_entry_id = Column(Integer, ForeignKey(MediaEntry.id))
-    comment_id = Column(Integer, ForeignKey(MediaComment.id))
-    resolver_id = Column(Integer, ForeignKey(User.id), nullable=False)
-    resolved_time = Column(DateTime)
-    result = Column(UnicodeText)
-
-class UserBan_v0(declarative_base()):
-    __tablename__ = 'core__user_bans'
-    user_id = Column('id',Integer, ForeignKey(User.id), nullable=False,
-                                         primary_key=True)
-    expiration_date = Column(DateTime)
-    reason = Column(UnicodeText, nullable=False)
-
-class Privilege_v0(declarative_base()):
-    __tablename__ = 'core__privileges'
-    id = Column(Integer, nullable=False, primary_key=True, unique=True)
-    privilege_name = Column(Unicode, nullable=False, unique=True)
-
-class PrivilegeUserAssociation_v0(declarative_base()):
-    __tablename__ = 'core__privileges_users'
-    group_id = Column(
-        'core__privilege_id', 
-        Integer, 
-        ForeignKey(User.id), 
-        primary_key=True)
-    user_id = Column(
-        'core__user_id', 
-        Integer, 
-        ForeignKey(Privilege.id), 
-        primary_key=True)
-
-@RegisterMigration(14, MIGRATIONS)
-def create_moderation_tables(db):
-    ReportBase_v0.__table__.create(db.bind)
-    CommentReport_v0.__table__.create(db.bind)
-    MediaReport_v0.__table__.create(db.bind)
-    ArchivedReport_v0.__table__.create(db.bind)
-    UserBan_v0.__table__.create(db.bind)
-    Privilege_v0.__table__.create(db.bind)
-    PrivilegeUserAssociation_v0.__table__.create(db.bind)
-    db.commit()
-
-
 # oauth1 migrations
 class Client_v0(declarative_base()):
     """
@@ -533,3 +460,77 @@ def create_oauth1_tables(db):
     NonceTimestamp_v0.__table__.create(db.bind)
 
     db.commit()
+
+class ReportBase_v0(declarative_base()):
+    __tablename__ = 'core__reports'
+    id = Column(Integer, primary_key=True)
+    reporter_id = Column(Integer, ForeignKey(User.id), nullable=False)
+    report_content = Column(UnicodeText)
+    reported_user_id = Column(Integer, ForeignKey(User.id), nullable=False)
+    created = Column(DateTime, nullable=False, default=datetime.datetime.now) 
+    discriminator = Column('type', Unicode(50))
+    __mapper_args__ = {'polymorphic_on': discriminator}
+
+class CommentReport_v0(ReportBase_v0):
+    __tablename__ = 'core__reports_on_comments'
+    __mapper_args__ = {'polymorphic_identity': 'comment_report'}
+
+    id = Column('id',Integer, ForeignKey('core__reports.id'),
+                                                primary_key=True)
+    comment_id = Column(Integer, ForeignKey(MediaComment.id), nullable=False)
+
+class MediaReport_v0(ReportBase_v0):
+    __tablename__ = 'core__reports_on_media'
+    __mapper_args__ = {'polymorphic_identity': 'media_report'}
+
+    id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
+    media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=False)
+
+class ArchivedReport_v0(ReportBase_v0):
+    __tablename__ = 'core__reports_archived'
+    __mapper_args__ = {'polymorphic_identity': 'archived_report'}
+
+    id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
+    media_entry_id = Column(Integer, ForeignKey(MediaEntry.id))
+    comment_id = Column(Integer, ForeignKey(MediaComment.id))
+    resolver_id = Column(Integer, ForeignKey(User.id), nullable=False)
+    resolved_time = Column(DateTime)
+    result = Column(UnicodeText)
+
+class UserBan_v0(declarative_base()):
+    __tablename__ = 'core__user_bans'
+    user_id = Column('id',Integer, ForeignKey(User.id), nullable=False,
+                                         primary_key=True)
+    expiration_date = Column(DateTime)
+    reason = Column(UnicodeText, nullable=False)
+
+class Privilege_v0(declarative_base()):
+    __tablename__ = 'core__privileges'
+    id = Column(Integer, nullable=False, primary_key=True, unique=True)
+    privilege_name = Column(Unicode, nullable=False, unique=True)
+
+class PrivilegeUserAssociation_v0(declarative_base()):
+    __tablename__ = 'core__privileges_users'
+    group_id = Column(
+        'core__privilege_id', 
+        Integer, 
+        ForeignKey(User.id), 
+        primary_key=True)
+    user_id = Column(
+        'core__user_id', 
+        Integer, 
+        ForeignKey(Privilege.id), 
+        primary_key=True)
+
+@RegisterMigration(15, MIGRATIONS)
+def create_moderation_tables(db):
+    ReportBase_v0.__table__.create(db.bind)
+    CommentReport_v0.__table__.create(db.bind)
+    MediaReport_v0.__table__.create(db.bind)
+    ArchivedReport_v0.__table__.create(db.bind)
+    UserBan_v0.__table__.create(db.bind)
+    Privilege_v0.__table__.create(db.bind)
+    PrivilegeUserAssociation_v0.__table__.create(db.bind)
+    db.commit()
+
+
index 25b4fa8f6b0217ac28f922ff30a7a3805bc73d1d..62c5a5d5d11c51ff3c1849a31eb2887d9036a980 100644 (file)
@@ -649,6 +649,10 @@ class ProcessingNotification(Notification):
         'polymorphic_identity': 'processing_notification'
     }
 
+with_polymorphic(
+    Notification,
+    [ProcessingNotification, CommentNotification])
+
 class ReportBase(Base):
     """
     This is the basic report table which the other reports are based off of.
@@ -828,16 +832,13 @@ class PrivilegeUserAssociation(Base):
         ForeignKey(Privilege.id), 
         primary_key=True)
 
-with_polymorphic(
-    Notification,
-    [ProcessingNotification, CommentNotification])
-
 MODELS = [
     User, MediaEntry, Tag, MediaTag, MediaComment, Collection, CollectionItem,
     MediaFile, FileKeynames, MediaAttachmentFile, ProcessingMetaData,
-    Notification, CommentNotification, ProcessingNotification,
+    Notification, CommentNotification, ProcessingNotification, Client,
     CommentSubscription, ReportBase, CommentReport, MediaReport, UserBan, 
-       Privilege, PrivilegeUserAssociation, ArchivedReport, ArchivedReport]
+       Privilege, PrivilegeUserAssociation, ArchivedReport,
+    RequestToken, AccessToken, NonceTimestamp]
 
 """
  Foundations are the default rows that are created immediately after the tables
index 7d7748ac3586b7c55fa5ea496b09086cd123de42..11ed83bded6b109f7d1edf0b3d55fbf9140ec2c3 100644 (file)
@@ -342,6 +342,7 @@ def authentication_disabled_app(request):
 
 def test_authentication_disabled_app(authentication_disabled_app):
     # app.auth should = false
+    assert mg_globals
     assert mg_globals.app.auth is False
 
     # Try to visit register page
index d70d0478fa5080b06f98c25647511e10ad98afb6..8db8a00db0d791bcd29af98c78557acf26a04fbb 100644 (file)
@@ -27,7 +27,8 @@ class TestUserEdit(object):
     def setup(self):
         # set up new user
         self.user_password = u'toast'
-        self.user = fixture_add_user(password = self.user_password)
+        self.user = fixture_add_user(password = self.user_password,
+                               privileges=[u'active'])
 
     def login(self, test_app):
         test_app.post(
@@ -52,7 +53,8 @@ class TestUserEdit(object):
         # deleted too. Perhaps in submission test?
 
         #Restore user at end of test
-        self.user = fixture_add_user(password = self.user_password)
+        self.user = fixture_add_user(password = self.user_password,
+                               privileges=[u'active'])
         self.login(test_app)
 
 
@@ -115,7 +117,8 @@ class TestUserEdit(object):
         assert test_user.url == u'http://dustycloud.org/'
 
         # change a different user than the logged in (should fail with 403)
-        fixture_add_user(username=u"foo")
+        fixture_add_user(username=u"foo",
+                         privileges=[u'active'])
         res = test_app.post(
             '/u/foo/edit/', {
                 'bio': u'I love toast!',
index d52b8d5aa32c510c414ad1b5f5c174a0c69f0359..8420e35897203114427eaf01ea00b26ea9848b9d 100644 (file)
@@ -38,7 +38,7 @@ class TestNotifications:
 
         # TODO: Possibly abstract into a decorator like:
         # @as_authenticated_user('chris')
-        self.test_user = fixture_add_user()
+        self.test_user = fixture_add_user(privileges=[u'active',u'commenter'])
 
         self.current_user = None
 
@@ -75,7 +75,10 @@ class TestNotifications:
 
         '''
         user = fixture_add_user('otherperson', password='nosreprehto',
-                                wants_comment_notification=wants_email)
+                                wants_comment_notification=wants_email,
+                                privileges=[u'active',u'commenter'])
+
+        assert user.wants_comment_notification == wants_email
 
         user_id = user.id
 
@@ -124,6 +127,8 @@ otherperson@example.com\n\nSGkgb3RoZXJwZXJzb24sCmNocmlzIGNvbW1lbnRlZCBvbiB5b3VyI
         else:
             assert mail.EMAIL_TEST_MBOX_INBOX == []
 
+        mail.EMAIL_TEST_MBOX_INBOX = []
+
         # Save the ids temporarily because of DetachedInstanceError
         notification_id = notification.id
         comment_id = notification.subject.id
index ac9410637bab31a8ceaa6a3b752fcd15763eb57b..dbdf87e9b40cdec45ddfce2a2f1d2e5bd77f4058 100644 (file)
@@ -46,7 +46,7 @@ class TestSubmission:
 
         # TODO: Possibly abstract into a decorator like:
         # @as_authenticated_user('chris')
-        test_user = fixture_add_user()
+        test_user = fixture_add_user(privileges=[u'active',u'uploader'])
 
         self.test_user = test_user
 
index ec17d79184c29b0cd23b1b36866c3537d64e1930..feb83b44c07842a00a4c855ae5cc9767582706ab 100644 (file)
@@ -133,7 +133,6 @@ def get_app(request, paste_config=None, mgoblin_config=None):
     mg_globals.app.meddleware.insert(0, TestingMeddleware(mg_globals.app))
 
     app = TestApp(test_app)
-
     return app