From 333d183cc95a7ae74ffdf5882fbf3d9c1058982d Mon Sep 17 00:00:00 2001 From: deepthivenkat Date: Wed, 6 Jul 2016 15:27:06 +0530 Subject: [PATCH] Issue #975 - Removed filter_new function and test_issues_new unit test --- tests/test_urls.py | 26 -------------------------- webcompat/api/endpoints.py | 5 ++++- webcompat/issues.py | 20 -------------------- 3 files changed, 4 insertions(+), 47 deletions(-) diff --git a/tests/test_urls.py b/tests/test_urls.py index 5151c887f..a80fcae17 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -14,8 +14,6 @@ sys.path.append(os.path.realpath(os.pardir)) import webcompat -from webcompat.issues import filter_new - # Any request that depends on parsing HTTP Headers (basically anything # on the index route, will need to include the following: environ_base=headers headers = {'HTTP_USER_AGENT': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; ' @@ -86,30 +84,6 @@ def test_issues_list_page(self): self.assertEqual(rv.status_code, 200) self.assertNotEqual(rv.status_code, 307) - def test_issues_new(self): - '''Test that the new filtering is correct.''' - issues = [ - {u'labels': [{u'name': u'bug'}, {u'name': u'help wanted'}], - u'title': u"fake bug 0", - u'id': 0}, - {u'labels': [], - u'title': u"fake bug 1", - u'id': 1}, - {u'labels': [{u'name': u'status-contactready'}], - u'title': u"fake bug 2", - u'id': 2}, - {u'labels': [{u'name': u'status-needsdiagnosis'}], - u'title': u"fake bug 3", - u'id': 3}, - {u'labels': [{u'name': u'status-needscontact'}], - u'title': u"fake bug 4", - u'id': 4}, - {u'labels': [{u'name': u'status-sitewait'}], - u'title': u"fake bug 5", - u'id': 5}] - result = '[{"labels": [{"name": "bug"}, {"name": "help wanted"}], "id": 0, "title": "fake bug 0"}, {"labels": [], "id": 1, "title": "fake bug 1"}]' # nopep8 - self.assertEqual(filter_new(issues), result) - def test_labeler_webhook(self): '''Test that the labeler webhook can respond to ping event.''' headers = {'X-GitHub-Event': 'ping'} diff --git a/webcompat/api/endpoints.py b/webcompat/api/endpoints.py index d4f8a2061..e6eb0c1c6 100644 --- a/webcompat/api/endpoints.py +++ b/webcompat/api/endpoints.py @@ -25,7 +25,6 @@ from webcompat.helpers import mockable_response from webcompat.helpers import normalize_api_params from webcompat.helpers import proxy_request -from webcompat.issues import filter_new api = Blueprint('api', __name__, url_prefix='/api') JSON_MIME = 'application/json' @@ -127,6 +126,8 @@ def get_issue_category(issue_category): # Note that 'needstriage' here is primarily used on the homepage. # For paginated results on the /issues page, # see /issues/search/needstriage. + # We abort with 301 here because the new endpoint has + # been replaced with needstriage. elif issue_category == 'new': abort(301) else: @@ -188,6 +189,8 @@ def get_category_from_search(issue_category): elif issue_category == 'closed': query_string += ' state:closed ' return get_search_results(query_string, params) + # We abort with 301 here because the new endpoint has + # been replaced with needstriage. elif issue_category == 'new': abort(301) else: diff --git a/webcompat/issues.py b/webcompat/issues.py index d2ed82aa9..d25d2b016 100644 --- a/webcompat/issues.py +++ b/webcompat/issues.py @@ -24,23 +24,3 @@ def report_issue(form, proxy=False): data=json.dumps(build_formdata(form))) else: return github.post(path, build_formdata(form)) - - -def filter_new(issues): - '''Return the list of "needs triage" issues, encoded as JSON. - This function gives all the "needs triage" issues. - ''' - def is_new(issue): - '''Filter function.''' - match = True - category_list = ['status-contactready', 'status-needscontact', - 'status-needsdiagnosis', 'status-sitewait'] - labels = [label.get('name') for label in issue.get('labels')] - # if the intersection of labels and category_list is not empty - # then it's not part of untriaged - common_cat = set(labels).intersection(category_list) - if common_cat: - match = False - return match - - return json.dumps([issue for issue in issues if is_new(issue)])