Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

Commit

Permalink
add tests for soring pickmes
Browse files Browse the repository at this point in the history
  • Loading branch information
Qi Qi committed Mar 20, 2015
1 parent 8f26adc commit 3a3282e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pushmanager/tests/test_template_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PushTemplateTest(TemplateTestCase):
'user': 'testuser',
'reviewid': 0,
'title': 'some title',
'tags': None,
'tags': 'seagull',
'revision': '0' * 40,
'state': 'requested',
'created': now,
Expand Down
42 changes: 42 additions & 0 deletions pushmanager/tests/test_ui_methods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import testify as T
from pushmanager.ui_methods import authorized_to_manage_request
from pushmanager.ui_methods import sort_pickmes


class UIMethodTest(T.TestCase):
Expand All @@ -20,6 +21,47 @@ def test_authorized_to_manage_request_watcher(self):
request = {'user': 'testuser', 'watchers': 'watcher1'}
T.assert_equal(True, authorized_to_manage_request(None, request, 'watcher1'))

def test_sort_pickmes_regular_case(self):
requests = [
{'tags': 'fake_tags'},
{'tags': 'urgent,no-verify'},
{'tags': 'urgent'},
{'tags': 'urgent,no-verify,seagull'},
]

sorted_requests = sort_pickmes(None, requests, ['urgent', 'no-verify', 'seagull'])
T.assert_equal(len(sorted_requests), 4)
T.assert_equal(sorted_requests[0], {'tags': 'urgent,no-verify,seagull'})
T.assert_equal(sorted_requests[1], {'tags': 'urgent,no-verify'})
T.assert_equal(sorted_requests[2], {'tags': 'urgent'})
T.assert_equal(sorted_requests[3], {'tags': 'fake_tags'})

def test_sort_pickmes_all_tags_in_ordering(self):
requests = [
{'tags': 'no-verify'},
{'tags': 'urgent'},
{'tags': 'seagull'},
]

sorted_requests = sort_pickmes(None, requests, ['urgent', 'no-verify', 'seagull'])
T.assert_equal(len(sorted_requests), 3)
T.assert_equal(sorted_requests[0], {'tags': 'urgent'})
T.assert_equal(sorted_requests[1], {'tags': 'no-verify'})
T.assert_equal(sorted_requests[2], {'tags': 'seagull'})

def test_sort_pickmes_no_tags_order(self):
requests = [
{'tags': 'no-verify'},
{'tags': 'urgent'},
{'tags': 'seagull'},
]

sorted_requests = sort_pickmes(None, requests, [])
T.assert_equal(len(sorted_requests), 3)
T.assert_equal(sorted_requests[0], {'tags': 'no-verify'})
T.assert_equal(sorted_requests[1], {'tags': 'urgent'})
T.assert_equal(sorted_requests[2], {'tags': 'seagull'})


if __name__ == '__main__':
T.run()

0 comments on commit 3a3282e

Please sign in to comment.