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 2019/11/13 16:33:47 UTC
[allura] 04/06: [#8340] tracker test coverage and remove dead code
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8340
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 1a797b5e9a89715411515f511bf11abb2b2851ea
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Nov 12 17:00:42 2019 -0500
[#8340] tracker test coverage and remove dead code
---
.../forgetracker/templates/tracker/bin.html | 1 -
.../forgetracker/templates/tracker/new_bin.html | 27 -----------------
.../forgetracker/tests/functional/test_root.py | 21 +++++++++++++
ForgeTracker/forgetracker/tests/test_app.py | 35 ++++++++++++++++++++++
ForgeTracker/forgetracker/tracker_main.py | 27 +++--------------
5 files changed, 60 insertions(+), 51 deletions(-)
diff --git a/ForgeTracker/forgetracker/templates/tracker/bin.html b/ForgeTracker/forgetracker/templates/tracker/bin.html
index 2f33ff3..d919ee6 100644
--- a/ForgeTracker/forgetracker/templates/tracker/bin.html
+++ b/ForgeTracker/forgetracker/templates/tracker/bin.html
@@ -17,7 +17,6 @@
under the License.
-#}
{% extends g.theme.master %}
-{% do g.register_forge_css('css/hilite.css') %}
{% do g.register_app_css('css/tracker.css') %}
{% block title %}{{c.project.name}} / {{app.config.options.mount_label}} / Saved Searches{% endblock %}
diff --git a/ForgeTracker/forgetracker/templates/tracker/new_bin.html b/ForgeTracker/forgetracker/templates/tracker/new_bin.html
deleted file mode 100644
index 6af78a7..0000000
--- a/ForgeTracker/forgetracker/templates/tracker/new_bin.html
+++ /dev/null
@@ -1,27 +0,0 @@
-{#-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--#}
-{% extends g.theme.master %}
-
-{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / New search for {{q}}{% endblock %}
-
-{% block header %}New search for {{q}}{% endblock %}
-
-{% block content %}
-{{c.bin_form.display(value=dict(summary=q,terms=q), action='save_bin')}}
-{% endblock %}
\ No newline at end of file
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 5eb9315..4456465 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -354,6 +354,27 @@ class TestFunctionalController(TrackerTestController):
r = self.app.get('/bugs/milestone_counts')
assert_equal(r.body, json.dumps(counts))
+ def test_bin_counts(self):
+ self.new_ticket(summary='test new')
+ self.new_ticket(summary='test new private', private=True)
+ M.MonQTask.run_ready()
+
+ r = self.app.get('/bugs/bin_counts')
+ assert_equal(r.json, {"bin_counts": [{"count": 2, "label": "Changes"},
+ {"count": 0, "label": "Closed Tickets"},
+ {"count": 2, "label": "Open Tickets"}]})
+
+ """
+ forgetracker.model.ticket.Globals.bin_count doesn't do a permission check like corresponding milestone_count
+
+ # Private tickets shouldn't be included in counts if user doesn't
+ # have read access to private tickets.
+ r = self.app.get('/bugs/bin_counts', extra_environ=dict(username='*anonymous'))
+ assert_equal(r.json, {"bin_counts": [{"count": 1, "label": "Changes"},
+ {"count": 0, "label": "Closed Tickets"},
+ {"count": 1, "label": "Open Tickets"}]})
+ """
+
def test_milestone_progress(self):
self.new_ticket(summary='Ticket 1', **{'_milestone': '1.0'})
self.new_ticket(summary='Ticket 2', **{'_milestone': '1.0',
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index cfc0596..8c416a9 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -24,6 +24,8 @@ from nose.tools import assert_equal, assert_true
from tg import tmpl_context as c
from cgi import FieldStorage
from cStringIO import StringIO
+
+from alluratest.controller import setup_basic_test
from ming.orm import ThreadLocalORMSession
from allura import model as M
@@ -32,6 +34,39 @@ from forgetracker import model as TM
from forgetracker.tests.functional.test_root import TrackerTestController
+class TestApp(object):
+
+ def setUp(self):
+ setup_basic_test()
+
+ @td.with_tracker
+ def test_inbound_email(self):
+ ticket = TM.Ticket.new()
+ ticket.summary = 'test ticket'
+ ticket.description = 'test description'
+
+ # send a message with no ticket matching it
+ message_id = '123@localhost'
+ message = 'test message'
+ msg = dict(payload=message, message_id=message_id, headers={'Subject': 'test'})
+ c.app.handle_message('1', msg)
+ # message gets added as a post on the ticket
+ post = M.Post.query.get(_id=message_id)
+ assert_equal(post["text"], message)
+
+ @td.with_tracker
+ def test_inbound_email_no_match(self):
+ # send a message with no ticket matching it
+ message_id = '123@localhost'
+ message = 'test message'
+ msg = dict(payload=message, message_id=message_id, headers={'Subject': 'test'})
+ # no ticket matching it
+ c.app.handle_message('6789', msg)
+ # no new message
+ post = M.Post.query.get(_id=message_id)
+ assert_equal(post, None)
+
+
class TestBulkExport(TrackerTestController):
@td.with_tracker
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index f4861a8..5f2f6e8 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -282,7 +282,9 @@ class ForgeTrackerApp(Application):
except:
log.exception('Error getting ticket %s', topic)
return
- if ticket.discussion_disabled:
+ if not ticket:
+ log.info('No such ticket num: %s', topic)
+ elif ticket.discussion_disabled:
log.info('Discussion disabled for ticket %s', ticket.ticket_num)
else:
self.handle_artifact_message(ticket, message)
@@ -1150,22 +1152,10 @@ class BinController(BaseController, AdminControllerMixin):
return dict(bins=self.app.bins, count=count, app=self.app)
@with_trailing_slash
- @expose('jinja:forgetracker:templates/tracker/bin.html')
- def bins(self):
- count = len(self.app.bins)
- return dict(bins=self.app.bins, count=count, app=self.app)
-
- @with_trailing_slash
- @expose('jinja:forgetracker:templates/tracker/new_bin.html')
- def newbin(self, q=None, **kw):
- c.bin_form = W.bin_form
- return dict(q=q or '', bin=bin or '', modelname='Bin', page='New Bin', globals=self.app.globals)
-
- @with_trailing_slash
@h.vardec
@expose('jinja:forgetracker:templates/tracker/bin.html')
@require_post()
- @validate(W.bin_form, error_handler=newbin)
+ @validate(W.bin_form, error_handler=index)
def save_bin(self, **bin_form):
"""Update existing search bin or create a new one.
@@ -1204,15 +1194,6 @@ class BinController(BaseController, AdminControllerMixin):
self.app.globals.invalidate_bin_counts()
redirect('.')
- @with_trailing_slash
- @expose()
- @require_post()
- @validate(validators=dict(bin=V.Ming(TM.Bin)))
- def delbin(self, bin=None):
- require(lambda: bin.app_config_id == self.app.config._id)
- bin.delete()
- redirect(request.referer or '/')
-
@without_trailing_slash
@h.vardec
@expose('jinja:forgetracker:templates/tracker/bin.html')