diff options
Diffstat (limited to 'mediagoblin/tests/test_edit.py')
-rw-r--r-- | mediagoblin/tests/test_edit.py | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/mediagoblin/tests/test_edit.py b/mediagoblin/tests/test_edit.py index dc9c422f..632c8e3c 100644 --- a/mediagoblin/tests/test_edit.py +++ b/mediagoblin/tests/test_edit.py @@ -14,10 +14,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import urlparse, os, pytest +import six +import six.moves.urllib.parse as urlparse +import pytest from mediagoblin import mg_globals -from mediagoblin.db.models import User, MediaEntry +from mediagoblin.db.models import User, LocalUser, MediaEntry from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry from mediagoblin import auth from mediagoblin.tools import template, mail @@ -42,12 +44,12 @@ class TestUserEdit(object): self.login(test_app) # Make sure user exists - assert User.query.filter_by(username=u'chris').first() + assert LocalUser.query.filter(LocalUser.username==u'chris').first() res = test_app.post('/edit/account/delete/', {'confirmed': 'y'}) # Make sure user has been deleted - assert User.query.filter_by(username=u'chris').first() == None + assert LocalUser.query.filter(LocalUser.username==u'chris').first() == None #TODO: make sure all corresponding items comments etc have been # deleted too. Perhaps in submission test? @@ -77,7 +79,7 @@ class TestUserEdit(object): 'bio': u'I love toast!', 'url': u'http://dustycloud.org/'}) - test_user = User.query.filter_by(username=u'chris').first() + test_user = LocalUser.query.filter(LocalUser.username==u'chris').first() assert test_user.bio == u'I love toast!' assert test_user.url == u'http://dustycloud.org/' @@ -142,8 +144,7 @@ class TestUserEdit(object): assert message['To'] == 'new@example.com' email_context = template.TEMPLATE_TEST_CONTEXT[ 'mediagoblin/edit/verification.txt'] - assert email_context['verification_url'] in \ - message.get_payload(decode=True) + assert email_context['verification_url'].encode('ascii') in message.get_payload(decode=True) path = urlparse.urlsplit(email_context['verification_url'])[2] assert path == u'/edit/verify_email/' @@ -158,9 +159,10 @@ class TestUserEdit(object): assert urlparse.urlsplit(res.location)[2] == '/' # Email shouldn't be saved - email_in_db = mg_globals.database.User.query.filter_by( - email='new@example.com').first() - email = User.query.filter_by(username='chris').first().email + email_in_db = mg_globals.database.LocalUser.query.filter( + LocalUser.email=='new@example.com' + ).first() + email = LocalUser.query.filter(LocalUser.username=='chris').first().email assert email_in_db is None assert email == 'chris@example.com' @@ -171,7 +173,7 @@ class TestUserEdit(object): res.follow() # New email saved? - email = User.query.filter_by(username='chris').first().email + email = LocalUser.query.filter(LocalUser.username=='chris').first().email assert email == 'new@example.com' # test changing the url inproperly @@ -180,8 +182,10 @@ class TestMetaDataEdit: def setup(self, test_app): # set up new user self.user_password = u'toast' - self.user = fixture_add_user(password = self.user_password, - privileges=[u'active',u'admin']) + self.user = fixture_add_user( + password = self.user_password, + privileges=[u'active',u'admin'] + ) self.test_app = test_app def login(self, test_app): @@ -250,5 +254,11 @@ class TestMetaDataEdit: old_metadata = new_metadata new_metadata = media_entry.media_metadata assert new_metadata == old_metadata - assert ("u'On the worst day' is not a 'date-time'" in - response.body) + context = template.TEMPLATE_TEST_CONTEXT[ + 'mediagoblin/edit/metadata.html'] + if six.PY2: + expected = "u'On the worst day' is not a 'date-time'" + else: + expected = "'On the worst day' is not a 'date-time'" + assert context['form'].errors[ + 'media_metadata'][0]['identifier'][0] == expected |