You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/02/02 20:18:23 UTC
[1/2] allura git commit: [#5726] Rss feed now updates correctly for
new topics.
Repository: allura
Updated Branches:
refs/heads/master 852360fd5 -> c9577b911
[#5726] Rss feed now updates correctly for new topics.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/ef5610b9
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/ef5610b9
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/ef5610b9
Branch: refs/heads/master
Commit: ef5610b98e87ecaed02fa7e3088f33ccfa14c918
Parents: 852360f
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Jan 29 17:23:56 2015 -0500
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Feb 2 18:23:51 2015 +0000
----------------------------------------------------------------------
.../forgediscussion/controllers/root.py | 3 +-
.../tests/functional/test_forum.py | 64 ++++++++++++++++++++
2 files changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/ef5610b9/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index cf1116e..9174fba 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -131,7 +131,8 @@ class RootController(BaseController, DispatchIndex, FeedController):
require_access(discussion, 'post')
thd = discussion.get_discussion_thread(dict(
headers=dict(Subject=subject)))[0]
- thd.post(subject, text)
+ p = thd.post(subject, text)
+ thd.post_to_feed(p)
flash('Message posted')
redirect(thd.url())
http://git-wip-us.apache.org/repos/asf/allura/blob/ef5610b9/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 34b71c9..3f45b46 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -27,6 +27,7 @@ from email.mime.multipart import MIMEMultipart
import pkg_resources
from pylons import tmpl_context as c
from nose.tools import assert_equal, assert_in
+import feedparser
from allura import model as M
from allura.tasks import mail_tasks
@@ -632,6 +633,69 @@ class TestForum(TestController):
r = self.app.get('/discussion/testforum/childforum/')
self.check_announcement_table(r, 'AAAA')
+ def test_post_to_feed(self):
+ # Create a new topic
+ r = self.app.get('/discussion/create_topic/')
+ f = r.html.find(
+ 'form', {'action': '/p/test/discussion/save_new_topic'})
+ params = dict()
+ inputs = f.findAll('input')
+ for field in inputs:
+ if field.has_key('name'):
+ params[field['name']] = field.has_key(
+ 'value') and field['value'] or ''
+ params[f.find('textarea')['name']] = 'XYZ'
+ params[f.find('select')['name']] = 'testforum'
+ params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAAA'
+ thread = self.app.post('/discussion/save_new_topic', params=params).follow()
+ url = thread.request.url
+
+ # Check that the newly created topic is the most recent in the rss feed
+ f = self.app.get('/discussion/feed.rss').body
+ f = feedparser.parse(f)
+ newest_entry = f['entries'][0]['summary_detail']['value'].split("</p>")[0].split("<p>")[-1]
+ assert newest_entry == 'XYZ'
+
+ # Reply to the newly created thread.
+ thread = self.app.get(url)
+ t = thread.html.find(
+ 'div', {'class': 'row reply_post_form'}).find('form')
+ rep_url = t.get('action')
+ params = dict()
+ inputs = t.findAll('input')
+ for field in inputs:
+ if field.has_key('name'):
+ params[field['name']] = field.has_key(
+ 'value') and field['value'] or ''
+ params[t.find('textarea')['name']] = 'bbb'
+ self.app.post(str(rep_url), params=params)
+
+ # Check that reply matches the newest in the rss feed
+ f = self.app.get('/discussion/feed.rss').body
+ f = feedparser.parse(f)
+ newest_reply = f['entries'][0]['summary_detail']['value'].split("</p>")[0].split("<p>")[-1]
+ assert newest_reply == 'bbb'
+
+ def test_post_to_feed(self):
+ r = self.app.get('/discussion/create_topic/')
+ f = r.html.find(
+ 'form', {'action': '/p/test/discussion/save_new_topic'})
+ params = dict()
+ inputs = f.findAll('input')
+ for field in inputs:
+ if field.has_key('name'):
+ params[field['name']] = field.has_key(
+ 'value') and field['value'] or ''
+ params[f.find('textarea')['name']] = 'XYZ'
+ params[f.find('select')['name']] = 'testforum'
+ params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAAA'
+ self.app.post('/discussion/save_new_topic', params=params)
+
+ f = self.app.get('/discussion/feed.rss').body
+ f = feedparser.parse(f)
+ newest_entry = f['entries'][0]['summary_detail']['value'].split("</p>")[0].split("<p>")[-1]
+ assert newest_entry == 'XYZ'
+
def test_thread_sticky(self):
r = self.app.get('/discussion/create_topic/')
f = r.html.find(
[2/2] allura git commit: [#5726] Refactored post_to_feed related
functional tests.
Posted by br...@apache.org.
[#5726] Refactored post_to_feed related functional tests.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/c9577b91
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c9577b91
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c9577b91
Branch: refs/heads/master
Commit: c9577b91192571e5267fe60f35299ac418b612d2
Parents: ef5610b
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Mon Feb 2 12:47:22 2015 -0500
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Feb 2 18:24:52 2015 +0000
----------------------------------------------------------------------
Allura/allura/templates/widgets/edit_post.html | 2 +-
.../templates/widgets/new_topic_post.html | 2 +-
.../forgediscussion/controllers/root.py | 1 +
.../tests/functional/test_forum.py | 85 ++++++++------------
4 files changed, 37 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/c9577b91/Allura/allura/templates/widgets/edit_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/edit_post.html b/Allura/allura/templates/widgets/edit_post.html
index a42803e..b3d814c 100644
--- a/Allura/allura/templates/widgets/edit_post.html
+++ b/Allura/allura/templates/widgets/edit_post.html
@@ -18,7 +18,7 @@
-#}
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
<div>
- <form method="post" action="{{action}}"
+ <form id="edit_{{ action[-4:] }}" method="post" action="{{action}}"
enctype="multipart/form-data">
{% if show_subject %}
<input name="{{ widget.context_for(widget.fields.subject)['rendered_name'] }}" style="width:97%"
http://git-wip-us.apache.org/repos/asf/allura/blob/c9577b91/Allura/allura/templates/widgets/new_topic_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/new_topic_post.html b/Allura/allura/templates/widgets/new_topic_post.html
index 1c03b94..c7f572a 100644
--- a/Allura/allura/templates/widgets/new_topic_post.html
+++ b/Allura/allura/templates/widgets/new_topic_post.html
@@ -17,7 +17,7 @@
under the License.
-#}
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
-<form method="post" action="{{action}}">
+<form id="create_new_topic" method="post" action="{{action}}">
{% if show_subject %}
<div class="grid-19"> </div>
<div class="grid-19">
http://git-wip-us.apache.org/repos/asf/allura/blob/c9577b91/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 9174fba..7548cd0 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -57,6 +57,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
class W(object):
forum_subscription_form = FW.ForumSubscriptionForm()
new_topic = DW.NewTopicPost(submit_text='Post')
+
announcements_table = FW.AnnouncementsTable()
add_forum = AddForumShort()
search_results = SearchResults()
http://git-wip-us.apache.org/repos/asf/allura/blob/c9577b91/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 3f45b46..732c5c5 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -40,7 +40,6 @@ log = logging.getLogger(__name__)
class TestForumEmail(TestController):
-
def setUp(self):
TestController.setUp(self)
c.user = M.User.by_username('test-admin')
@@ -127,7 +126,6 @@ class TestForumEmail(TestController):
class TestForumAsync(TestController):
-
def setUp(self):
TestController.setUp(self)
self.app.get('/discussion/')
@@ -269,7 +267,6 @@ class TestForumAsync(TestController):
class TestForum(TestController):
-
def setUp(self):
TestController.setUp(self)
self.app.get('/discussion/')
@@ -290,6 +287,33 @@ class TestForum(TestController):
r = self.app.get('/admin/discussion/forums')
assert 'childforum' in r
+ @staticmethod
+ def fill_thread_reply(r):
+ form = r.forms['edit_post']
+ for field in form.fields.values():
+ field = field[0]
+ if field.id is None:
+ continue
+ if 'text' in field.id:
+ form[field.name] = 'Test_Reply'
+ return form
+
+ @staticmethod
+ def fill_new_topic_form(r):
+ form = r.forms['create_new_topic']
+ for field in form.fields.values():
+ field = field[0]
+ if field.id is None:
+ continue
+ if 'subject' in field.id:
+ form[field.name] = 'Test_Subject'
+ if 'forum' in field.id:
+ form[field.name] = 'testforum'
+ if 'text' in field.id:
+ form[field.name] = 'Test_Description'
+ return form
+
+
def test_unicode_name(self):
r = self.app.get('/admin/discussion/forums')
r.forms[1]['add_forum.shortname'] = u'téstforum'.encode('utf-8')
@@ -559,8 +583,7 @@ class TestForum(TestController):
'value') and field['value'] or ''
params[f.find('textarea')['name']] = 'Post text'
params[f.find('select')['name']] = 'testforum'
- params[f.find('input', {'style': 'width: 90%'})
- ['name']] = 'Post subject'
+ params[f.find('input', {'style': 'width: 90%'})['name']] = 'Post subject'
thread = self.app.post(
'/discussion/save_new_topic', params=params).follow()
assert M.Notification.query.find(
@@ -636,65 +659,26 @@ class TestForum(TestController):
def test_post_to_feed(self):
# Create a new topic
r = self.app.get('/discussion/create_topic/')
- f = r.html.find(
- 'form', {'action': '/p/test/discussion/save_new_topic'})
- params = dict()
- inputs = f.findAll('input')
- for field in inputs:
- if field.has_key('name'):
- params[field['name']] = field.has_key(
- 'value') and field['value'] or ''
- params[f.find('textarea')['name']] = 'XYZ'
- params[f.find('select')['name']] = 'testforum'
- params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAAA'
- thread = self.app.post('/discussion/save_new_topic', params=params).follow()
+ form = self.fill_new_topic_form(r)
+ thread = form.submit().follow()
url = thread.request.url
# Check that the newly created topic is the most recent in the rss feed
f = self.app.get('/discussion/feed.rss').body
f = feedparser.parse(f)
newest_entry = f['entries'][0]['summary_detail']['value'].split("</p>")[0].split("<p>")[-1]
- assert newest_entry == 'XYZ'
+ assert newest_entry == 'Test_Description'
# Reply to the newly created thread.
thread = self.app.get(url)
- t = thread.html.find(
- 'div', {'class': 'row reply_post_form'}).find('form')
- rep_url = t.get('action')
- params = dict()
- inputs = t.findAll('input')
- for field in inputs:
- if field.has_key('name'):
- params[field['name']] = field.has_key(
- 'value') and field['value'] or ''
- params[t.find('textarea')['name']] = 'bbb'
- self.app.post(str(rep_url), params=params)
+ form = self.fill_thread_reply(thread)
+ form.submit()
# Check that reply matches the newest in the rss feed
f = self.app.get('/discussion/feed.rss').body
f = feedparser.parse(f)
newest_reply = f['entries'][0]['summary_detail']['value'].split("</p>")[0].split("<p>")[-1]
- assert newest_reply == 'bbb'
-
- def test_post_to_feed(self):
- r = self.app.get('/discussion/create_topic/')
- f = r.html.find(
- 'form', {'action': '/p/test/discussion/save_new_topic'})
- params = dict()
- inputs = f.findAll('input')
- for field in inputs:
- if field.has_key('name'):
- params[field['name']] = field.has_key(
- 'value') and field['value'] or ''
- params[f.find('textarea')['name']] = 'XYZ'
- params[f.find('select')['name']] = 'testforum'
- params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAAA'
- self.app.post('/discussion/save_new_topic', params=params)
-
- f = self.app.get('/discussion/feed.rss').body
- f = feedparser.parse(f)
- newest_entry = f['entries'][0]['summary_detail']['value'].split("</p>")[0].split("<p>")[-1]
- assert newest_entry == 'XYZ'
+ assert newest_reply == 'Test_Reply'
def test_thread_sticky(self):
r = self.app.get('/discussion/create_topic/')
@@ -884,7 +868,6 @@ class TestForum(TestController):
class TestForumStats(TestController):
-
def test_stats(self):
self.app.get('/discussion/stats', status=200)