Add test to check that an activity is created when a collection was chosen.
This commit is contained in:
parent
5f60a4550d
commit
43cf0a68f2
@ -36,7 +36,7 @@ Gst.init(None)
|
|||||||
from mediagoblin.tests.tools import fixture_add_user, fixture_add_collection
|
from mediagoblin.tests.tools import fixture_add_user, fixture_add_collection
|
||||||
from .media_tools import create_av
|
from .media_tools import create_av
|
||||||
from mediagoblin import mg_globals
|
from mediagoblin import mg_globals
|
||||||
from mediagoblin.db.models import MediaEntry, User, LocalUser
|
from mediagoblin.db.models import MediaEntry, User, LocalUser, Activity
|
||||||
from mediagoblin.db.base import Session
|
from mediagoblin.db.base import Session
|
||||||
from mediagoblin.tools import template
|
from mediagoblin.tools import template
|
||||||
from mediagoblin.media_types.image import ImageMediaManager
|
from mediagoblin.media_types.image import ImageMediaManager
|
||||||
@ -426,14 +426,14 @@ class TestSubmission:
|
|||||||
def test_collection_selection(self):
|
def test_collection_selection(self):
|
||||||
"""Test the ability to choose a collection when submitting media
|
"""Test the ability to choose a collection when submitting media
|
||||||
"""
|
"""
|
||||||
# Collection option shouldn't be present if the user has no collections
|
# Collection option should have been removed if the user has no
|
||||||
|
# collections.
|
||||||
response = self.test_app.get('/submit/')
|
response = self.test_app.get('/submit/')
|
||||||
assert 'collection' not in response.form.fields
|
assert 'collection' not in response.form.fields
|
||||||
|
|
||||||
|
# Test upload of an image when a user has no collections.
|
||||||
upload = webtest.forms.Upload(os.path.join(
|
upload = webtest.forms.Upload(os.path.join(
|
||||||
'mediagoblin', 'static', 'images', 'media_thumbs', 'image.png'))
|
'mediagoblin', 'static', 'images', 'media_thumbs', 'image.png'))
|
||||||
|
|
||||||
# Check that upload of an image when a user has no collections
|
|
||||||
response.form['file'] = upload
|
response.form['file'] = upload
|
||||||
no_collection_title = 'no collection'
|
no_collection_title = 'no collection'
|
||||||
response.form['title'] = no_collection_title
|
response.form['title'] = no_collection_title
|
||||||
@ -466,6 +466,13 @@ class TestSubmission:
|
|||||||
col = self.our_user().collections[0]
|
col = self.our_user().collections[0]
|
||||||
assert col.collection_items[0].get_object().title == title
|
assert col.collection_items[0].get_object().title == title
|
||||||
|
|
||||||
|
# Test that an activity was created when the item was added to the
|
||||||
|
# collection. That should be the last activity.
|
||||||
|
assert Activity.query.order_by(
|
||||||
|
Activity.id.desc()
|
||||||
|
).first().content == '{0} added new picture to {1}'.format(
|
||||||
|
self.our_user().username, col.title)
|
||||||
|
|
||||||
# Test upload succeeds if the user has collection and no collection is
|
# Test upload succeeds if the user has collection and no collection is
|
||||||
# chosen.
|
# chosen.
|
||||||
form['file'] = webtest.forms.Upload(os.path.join(
|
form['file'] = webtest.forms.Upload(os.path.join(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user