allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [14/16] allura git commit: [#8230] Add unit tests for get_markdown and update_markdown
Date Mon, 15 Oct 2018 16:02:38 GMT
[#8230] Add unit tests for get_markdown and update_markdown


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/77cceb05
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/77cceb05
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/77cceb05

Branch: refs/heads/master
Commit: 77cceb058f10e79ed0f7d32c07f0dbe9ce6c7845
Parents: 17208f3
Author: Shalitha Suranga <shalithasuranga@gmail.com>
Authored: Fri Oct 12 15:32:52 2018 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Oct 15 15:50:29 2018 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_discuss.py  | 25 +++++++++++++++
 .../forgeblog/tests/functional/test_root.py     | 22 +++++++++++++
 .../forgetracker/tests/functional/test_root.py  | 21 +++++++++++++
 .../forgewiki/tests/functional/test_root.py     | 33 ++++++++++++++++++++
 4 files changed, 101 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/77cceb05/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 5a31272..74a490c 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -191,6 +191,31 @@ class TestDiscuss(TestDiscussBase):
         assert M.Post.query.find().count() == 1
         assert M.Post.query.find({'deleted': False}).count() == 0
 
+    def test_comment_get_markdown(self):
+        r = self._make_post('This is a post')
+        post_id = str(
+            r.html.find('div', {'class': 'discussion-post'})['id'])
+        response = self.app.get(self._thread_link() + post_id + '/get_markdown')
+        assert 'This is a post' in response
+
+    def test_comment_update_markdown(self):
+        r = self._make_post('This is a post')
+        post_id = str(
+            r.html.find('div', {'class': 'discussion-post'})['id'])
+        update_link = str(self._thread_link() + post_id + '/update_markdown')
+        response = self.app.post(
+            update_link,
+            params={
+                'text': '- [x] checkbox'})
+        assert response.json['status'] == 'success'
+        # anon users can't edit markdown
+        response = self.app.post(
+            update_link,
+            params={
+                'text': '- [x] checkbox'},
+            extra_environ=dict(username='*anonymous'))
+        assert response.json['status'] == 'no_permission'
+
     def test_user_filter(self):
         r = self._make_post('Test post')
         post_link = str(

http://git-wip-us.apache.org/repos/asf/allura/blob/77cceb05/ForgeBlog/forgeblog/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/functional/test_root.py b/ForgeBlog/forgeblog/tests/functional/test_root.py
index 4085744..972aa1a 100644
--- a/ForgeBlog/forgeblog/tests/functional/test_root.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_root.py
@@ -161,6 +161,28 @@ class Test(TestController):
                                 extra_environ=dict(username='*anonymous'))
         assert 'Nothing' not in response
 
+    def test_post_get_markdown(self):
+        self._post()
+        d = self._blog_date()
+        response = self.app.get('/blog/%s/my-post/get_markdown' % d)
+        assert 'Nothing' in response
+
+    def test_post_update_markdown(self):
+        self._post()
+        d = self._blog_date()
+        response = self.app.post(
+            '/blog/%s/my-post/update_markdown' % d,
+            params={
+                'text': '- [x] checkbox'})
+        assert response.json['status'] == 'success'
+        # anon users can't edit markdown
+        response = self.app.post(
+            '/blog/%s/my-post/update_markdown' % d,
+            params={
+                'text': '- [x] checkbox'},
+            extra_environ=dict(username='*anonymous'))
+        assert response.json['status'] == 'no_permission'
+
     def test_post_attachments(self):
         # create
         upload = ('attachment', 'nums.txt', '123412341234')

http://git-wip-us.apache.org/repos/asf/allura/blob/77cceb05/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index adf39c3..f9a5317 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -307,6 +307,27 @@ class TestFunctionalController(TrackerTestController):
         assert_true(summary in ticket_view)
         opts = self.subscription_options(ticket_view)
         assert_equal(opts['subscribed'], False)
+        
+    def test_ticket_get_markdown(self):
+        self.new_ticket(summary='my ticket', description='my description')
+        response = self.app.get('/bugs/1/get_markdown')
+        assert 'my description' in response
+
+    def test_ticket_update_markdown(self):
+        self.new_ticket(summary='my ticket', description='my description')
+        response = self.app.get('/bugs/1/get_markdown')
+        response = self.app.post(
+            '/bugs/1/update_markdown',
+            params={
+                'text': '- [x] checkbox'})
+        assert response.json['status'] == 'success'
+        # anon users can't edit markdown
+        response = self.app.post(
+            '/bugs/1/update_markdown',
+            params={
+                'text': '- [x] checkbox'},
+            extra_environ=dict(username='*anonymous'))
+        assert response.json['status'] == 'no_permission'
 
     def test_labels(self):
         ticket_view = self.new_ticket(summary='summary', labels="test label").follow()

http://git-wip-us.apache.org/repos/asf/allura/blob/77cceb05/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 98533eb..8781406 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -400,6 +400,39 @@ class TestRootController(TestController):
         assert_equal(spam_checker.check.call_args[0][0], u'tést\nsometext')
         assert 'tést' in response
 
+    def test_page_get_markdown(self):
+        self.app.post(
+            '/wiki/tést/update',
+            params={
+                'title': 'tést',
+                'text': '- [ ] checkbox',
+                'labels': '',
+                'viewable_by-0.id': 'all'})
+        response = self.app.get('/wiki/tést/get_markdown')
+        assert '- [ ] checkbox' in response
+
+
+    def test_page_update_markdown(self):
+        self.app.post(
+            '/wiki/tést/update',
+            params={
+                'title': 'tést',
+                'text': '- [ ] checkbox',
+                'labels': '',
+                'viewable_by-0.id': 'all'})
+        response = self.app.post(
+            '/wiki/tést/update_markdown',
+            params={
+                'text': '- [x] checkbox'})
+        assert response.json['status'] == 'success'
+        # anon users can't edit markdown
+        response = self.app.post(
+            '/wiki/tést/update_markdown',
+            params={
+                'text': '- [x] checkbox'},
+            extra_environ=dict(username='*anonymous'))
+        assert response.json['status'] == 'no_permission'
+
     def test_page_label_unlabel(self):
         self.app.get('/wiki/tést/')
         response = self.app.post(


Mime
View raw message