Merge remote branch 'remotes/gullydwarf-cfdv/f360_tagging' into mergetags
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 30 Jul 2011 18:37:33 +0000 (13:37 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 30 Jul 2011 18:37:33 +0000 (13:37 -0500)
Conflicts:
mediagoblin/tests/test_submission.py

1  2 
mediagoblin/tests/test_submission.py

index 22b6117c7233d92026e23fb7f1e7e120c6eca408,7c6b0f750a86d3f81f5c5799b29904838e89dc95..a72482555b426328b553074fd14327688076b55b
@@@ -110,7 -113,45 +113,43 @@@ class TestSubmission
          assert util.TEMPLATE_TEST_CONTEXT.has_key(
              'mediagoblin/user_pages/user.html')
  
 -
+     def test_tags(self):
+         # Good tag string
+         # --------
+         util.clear_test_template_context()
+         response = self.test_app.post(
+             '/submit/', {
+                 'title': 'Balanced Goblin',
+                 'tags': GOOD_TAG_STRING
+                 }, upload_files=[(
+                     'file', GOOD_JPG)])
+         # New media entry with correct tags should be created
+         response.follow()
+         context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/user_pages/user.html']
+         request = context['request']
+         media = request.db.MediaEntry.find({'title': 'Balanced Goblin'})[0]
+         assert_equal(media['tags'],
+                      [{'name': u'yin', 'slug': u'yin'},
+                                             {'name': u'yang', 'slug': u'yang'}])
+         # Test tags that are too long
+         # ---------------
+         util.clear_test_template_context()
+         response = self.test_app.post(
+             '/submit/', {
+                 'title': 'Balanced Goblin',
+                 'tags': BAD_TAG_STRING
+                 }, upload_files=[(
+                     'file', GOOD_JPG)])
+         # Too long error should be raised
+         context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/submit/start.html']
+         form = context['submit_form']
+         assert form.tags.errors == [
+             u'Tags must be shorter than 50 characters.  Tags that are too long'\
+              ': ffffffffffffffffffffffffffuuuuuuuuuuuuuuuuuuuuuuuuuu']
  
 -
      def test_malicious_uploads(self):
          # Test non-suppoerted file with non-supported extension
          # -----------------------------------------------------