From 19ef92f84585198ee67cdcf9b37973b767409feb Mon Sep 17 00:00:00 2001
From: tom <tom@teamfay.co.uk>
Date: Sat, 12 Dec 2015 11:29:27 +0000
Subject: [PATCH 2/2] Add test to check that an activity is created when a
collection was chosen.
---
mediagoblin/tests/test_submission.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py
index eed7afa..0ec49ec 100644
|
a
|
b
|
Gst.init(None)
|
| 36 | 36 | from mediagoblin.tests.tools import fixture_add_user, fixture_add_collection |
| 37 | 37 | from .media_tools import create_av |
| 38 | 38 | from mediagoblin import mg_globals |
| 39 | | from mediagoblin.db.models import MediaEntry, User, LocalUser |
| | 39 | from mediagoblin.db.models import MediaEntry, User, LocalUser, Activity |
| 40 | 40 | from mediagoblin.db.base import Session |
| 41 | 41 | from mediagoblin.tools import template |
| 42 | 42 | from mediagoblin.media_types.image import ImageMediaManager |
| … |
… |
class TestSubmission:
|
| 426 | 426 | def test_collection_selection(self): |
| 427 | 427 | """Test the ability to choose a collection when submitting media |
| 428 | 428 | """ |
| 429 | | # Collection option shouldn't be present if the user has no collections |
| | 429 | # Collection option should have been removed if the user has no |
| | 430 | # collections. |
| 430 | 431 | response = self.test_app.get('/submit/') |
| 431 | 432 | assert 'collection' not in response.form.fields |
| 432 | 433 | |
| | 434 | # Test upload of an image when a user has no collections. |
| 433 | 435 | upload = webtest.forms.Upload(os.path.join( |
| 434 | 436 | 'mediagoblin', 'static', 'images', 'media_thumbs', 'image.png')) |
| 435 | | |
| 436 | | # Check that upload of an image when a user has no collections |
| 437 | 437 | response.form['file'] = upload |
| 438 | 438 | no_collection_title = 'no collection' |
| 439 | 439 | response.form['title'] = no_collection_title |
| … |
… |
class TestSubmission:
|
| 466 | 466 | col = self.our_user().collections[0] |
| 467 | 467 | assert col.collection_items[0].get_object().title == title |
| 468 | 468 | |
| | 469 | # Test that an activity was created when the item was added to the |
| | 470 | # collection. That should be the last activity. |
| | 471 | assert Activity.query.order_by( |
| | 472 | Activity.id.desc() |
| | 473 | ).first().content == '{0} added new picture to {1}'.format( |
| | 474 | self.our_user().username, col.title) |
| | 475 | |
| 469 | 476 | # Test upload succeeds if the user has collection and no collection is |
| 470 | 477 | # chosen. |
| 471 | 478 | form['file'] = webtest.forms.Upload(os.path.join( |