import pushmanager.testing as T from pushmanager.ui_methods import authorized_to_manage_request class UIMethodTest(T.TestCase): def test_authorized_to_manage_request_random_user(self): request = {'user': '******', 'watchers': None } T.assert_equal(False, authorized_to_manage_request(None, request, 'notme')) def test_authorized_to_manage_request_request_user(self): request = {'user': '******', 'watchers': None } T.assert_equal(True, authorized_to_manage_request(None, request, 'testuser')) def test_authorized_to_manage_request_pushmaster(self): request = {'user': '******', 'watchers': None } T.assert_equal(True, authorized_to_manage_request(None, request, 'notme', True)) def test_authorized_to_manage_request_watcher(self): request = {'user': '******', 'watchers': 'watcher1' } T.assert_equal(True, authorized_to_manage_request(None, request, 'watcher1')) if __name__ == '__main__': T.run()
found_name = [] for field in tree.iter('input'): if 'type' not in field.attrib or field.attrib['type'] in ['checkbox']: # ignore hidden/submit found_id.append(field.attrib['id']) found_name.append(field.attrib['name']) for textarea in tree.iter('textarea'): found_id.append(textarea.attrib['id']) found_name.append(textarea.attrib['name']) T.assert_sorted_equal(id_attr, found_id) T.assert_sorted_equal(name_attr, found_name) tags = ['feature', 'fix' ,'cleanup', 'buildbot', 'caches', 'pushplans', 'special', 'urgent', 'l10n', 'l10n-only', 'hoods', 'stagea', 'stageb', 'no-verify'] def test_request_quicktags(self): tree = self.render_etree(self.newrequest_page) found_tags = [] for span in tree.iter('span'): if span.attrib['class'] == 'tag-suggestion': found_tags.append(span.text) T.assert_sorted_equal(self.tags, found_tags) if __name__ == '__main__': T.run()