Skip to content

Commit

Permalink
Issue webcompat#975 - Removed filter_new function and test_issues_new…
Browse files Browse the repository at this point in the history
… unit test
  • Loading branch information
deepthivenkat committed Jul 6, 2016
1 parent d9eeb79 commit 333d183
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 47 deletions.
26 changes: 0 additions & 26 deletions tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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; '
Expand Down Expand Up @@ -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'}
Expand Down
5 changes: 4 additions & 1 deletion webcompat/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
20 changes: 0 additions & 20 deletions webcompat/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])

0 comments on commit 333d183

Please sign in to comment.