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/04/16 19:43:21 UTC
[1/3] allura git commit: [#7852] Added tests to confirm 'mod_time'
field does not get updated on page view.
Repository: allura
Updated Branches:
refs/heads/master ad7c5f9cc -> 3d7b62b2e
[#7852] Added tests to confirm 'mod_time' field does not get updated on page view.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/fc066e31
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/fc066e31
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/fc066e31
Branch: refs/heads/master
Commit: fc066e31bb244c1445b19def36a2d70fa0fdd1c3
Parents: b5b01d0
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Tue Apr 14 13:31:12 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Apr 16 13:04:18 2015 -0400
----------------------------------------------------------------------
.../forgetracker/templates/tracker/ticket.html | 2 +-
.../forgetracker/tests/functional/test_root.py | 21 ++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/fc066e31/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index 27331c8..5f9f534 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -123,7 +123,7 @@
<div style="clear:both"></div>
<div class="grid-4">
<label class="simple">Updated:</label>
- {{abbr_date(ticket.mod_date)}}
+ <span id="updated_id">{{abbr_date(ticket.mod_date)}}</span>
</div>
<div class="grid-4">
<label class="simple">Created:</label>
http://git-wip-us.apache.org/repos/asf/allura/blob/fc066e31/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 21a3564..d096010 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -16,6 +16,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from datetime import datetime
import urllib
import os
@@ -720,6 +721,26 @@ class TestFunctionalController(TrackerTestController):
r = self.app.get('/bugs/markdown_syntax')
assert_true('Markdown Syntax' in r)
+ @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='0')
+ @patch('allura.lib.app_globals.ForgeMarkdown.cached_convert')
+ def test_cached_convert(self, mock_cached_convert):
+ from allura.model.session import artifact_orm_session
+ # Create ticket
+ params = dict(ticket_num=1,
+ app_config_id=c.app.config._id,
+ summary=u'test md cache',
+ mod_date=datetime(2010, 1, 1, 1, 1, 1))
+ ticket = tm.Ticket(**params)
+ session = artifact_orm_session._get()
+ setattr(session, 'skip_mod_date', True)
+
+ # This visit will cause cache to be stored on the artifact.
+ # We want to make sure the 'last_updated' field isn't updated by the cache creation
+ r = self.app.get('/bugs/1').follow()
+ last_updated = r.html.find("span", {"id": "updated_id"}).text
+ assert_equal(last_updated, '2010-01-01')
+ assert_equal(mock_cached_convert.call_count, 1)
+
def test_ticket_diffs(self):
self.new_ticket(summary='difftest', description='1\n2\n3\n')
self.app.post('/bugs/1/update_ticket', {
[2/3] allura git commit: [#7852] Fixed an issue where 'mod_time' was
getting updated on the first view.
Posted by br...@apache.org.
[#7852] Fixed an issue where 'mod_time' was getting updated on the first view.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b5b01d01
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b5b01d01
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b5b01d01
Branch: refs/heads/master
Commit: b5b01d01f8d9d3cc25e0e0681480e5fc3b2b1a07
Parents: ad7c5f9
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Tue Apr 14 13:29:20 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Apr 16 13:04:18 2015 -0400
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b5b01d01/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 30bfbf3..31f3c79 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -63,6 +63,7 @@ from allura.lib.widgets import analytics
from allura.lib.security import Credentials
from allura.lib.solr import MockSOLR, make_solr_from_config
from allura.lib.zarkov_helpers import ZarkovClient
+from allura.model.session import artifact_orm_session
log = logging.getLogger(__name__)
@@ -104,11 +105,13 @@ class ForgeMarkdown(markdown.Markdown):
return self.convert(source_text)
md5 = None
+ # If a cached version exists and it is valid, return it.
if cache.md5 is not None:
md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
if cache.md5 == md5 and getattr(cache, 'fix7528', False):
return h.html.literal(cache.html)
+ # Convert the markdown and time the result.
start = time.time()
html = self.convert(source_text)
render_time = time.time() - start
@@ -121,11 +124,16 @@ class ForgeMarkdown(markdown.Markdown):
log.warn('Skipping Markdown caching - The value for config param '
'"markdown_cache_threshold" must be a float.')
- if threshold != None and render_time > threshold:
+ if threshold is not None and render_time > threshold:
+ # Save the cache
if md5 is None:
md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
cache.md5, cache.html, cache.render_time = md5, html, render_time
cache.fix7528 = True # flag to indicate good caches created after [#7528] was fixed
+
+ # Prevent cache creation from updating the mod_date timestamp.
+ _session = artifact_orm_session._get()
+ setattr(_session, 'skip_mod_date', True)
return html
[3/3] allura git commit: [#7852] Removed cached_convert mock from
test_cached_convert.
Posted by br...@apache.org.
[#7852] Removed cached_convert mock from test_cached_convert.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/3d7b62b2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/3d7b62b2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/3d7b62b2
Branch: refs/heads/master
Commit: 3d7b62b2e3f510ee1e935817251a78c71aecfc86
Parents: fc066e3
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Apr 16 13:03:47 2015 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Apr 16 17:30:12 2015 +0000
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 2 +-
.../forgetracker/tests/functional/test_root.py | 13 +++++++++----
2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/3d7b62b2/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 31f3c79..e9879de 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -133,7 +133,7 @@ class ForgeMarkdown(markdown.Markdown):
# Prevent cache creation from updating the mod_date timestamp.
_session = artifact_orm_session._get()
- setattr(_session, 'skip_mod_date', True)
+ _session.skip_mod_date = True
return html
http://git-wip-us.apache.org/repos/asf/allura/blob/3d7b62b2/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 d096010..e8195d5 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -722,24 +722,29 @@ class TestFunctionalController(TrackerTestController):
assert_true('Markdown Syntax' in r)
@patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='0')
- @patch('allura.lib.app_globals.ForgeMarkdown.cached_convert')
- def test_cached_convert(self, mock_cached_convert):
+ def test_cached_convert(self):
from allura.model.session import artifact_orm_session
# Create ticket
params = dict(ticket_num=1,
app_config_id=c.app.config._id,
summary=u'test md cache',
+ description=u'# Test markdown cached_convert',
mod_date=datetime(2010, 1, 1, 1, 1, 1))
ticket = tm.Ticket(**params)
+
+ # Enable skip_mod_date to prevent mod_date from being set automatically when the ticket is saved.
session = artifact_orm_session._get()
- setattr(session, 'skip_mod_date', True)
+ session.skip_mod_date = True
# This visit will cause cache to be stored on the artifact.
# We want to make sure the 'last_updated' field isn't updated by the cache creation
r = self.app.get('/bugs/1').follow()
last_updated = r.html.find("span", {"id": "updated_id"}).text
assert_equal(last_updated, '2010-01-01')
- assert_equal(mock_cached_convert.call_count, 1)
+
+ # Make sure the cache has been saved.
+ t = tm.Ticket.query.find({'_id': ticket._id}).first()
+ assert_in('<h1 id="test-markdown-cached_convert">Test markdown cached_convert</h1>', t.description_cache.html)
def test_ticket_diffs(self):
self.new_ticket(summary='difftest', description='1\n2\n3\n')