def test_change_status(self): review_app = SubmitReviewsApp(datadir="../data", app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='nothing') msg = 'Something completely different' cases = {'clear': (True, True, True, True, None, None), 'progress': (False, True, True, True, msg, None), 'fail': (True, False, True, True, None, msg), 'success': (True, True, False, True, msg, None), 'warning': (True, True, True, False, msg, None), } review_app.run() for status in cases: review_app._change_status(status, msg) spinner, error, success, warn, label, error_detail = cases[status] self.assertEqual(spinner, review_app.submit_spinner.get_parent() is None) self.assertEqual(error, review_app.submit_error_img.get_window() is None) self.assertEqual(success, review_app.submit_success_img.get_window() is None) self.assertEqual(warn, review_app.submit_warn_img.get_window() is None) if label: self.assertEqual(label, review_app.label_transmit_status.get_text()) if error_detail: buff = review_app.error_textview.get_buffer() self.assertEqual(error_detail, buff.get_text(buff.get_start_iter(), buff.get_end_iter(), include_hidden_chars=False)) review_app.detail_expander.get_visible()
def test_get_fade_colour_markup(self): review_app = SubmitReviewsApp(datadir="../data", app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='nothing') cases = ( (('006000', '00A000', 40, 60, 50), ('008000', 10)), (('000000', 'FFFFFF', 40, 40, 40), ('000000', 0)), (('000000', '808080', 100, 400, 40), ('000000', 360)), (('000000', '808080', 100, 400, 1000), ('808080', -600)), (('123456', '5294D6', 10, 90, 70), ('427CB6', 20)), ) for args, return_value in cases: result = review_app._get_fade_colour_markup(*args) expected = '<span fgcolor="#%s">%s</span>' % return_value self.assertEqual(expected, result)
def test_modify_review_is_the_same_supports_unicode(self): review_app = SubmitReviewsApp(datadir="../data", app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='modify', review_id=10000) self.assertTrue(review_app._modify_review_is_the_same()) cases = ('', 'e', ')!') for case in cases: modified = review_app.orig_summary_text[:-1] + case review_app.review_summary_entry.set_text(modified) self.assertFalse(review_app._modify_review_is_the_same()) review_app.review_summary_entry.set_text(review_app.orig_summary_text) for case in cases: modified = review_app.orig_review_text[:-1] + case review_app.review_buffer.set_text(modified) self.assertFalse(review_app._modify_review_is_the_same())
def test_edit_review_screen_has_right_labels(self): """Check that LP #880255 stays fixed. """ review_app = SubmitReviewsApp(datadir="../data", app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='modify', review_id=10000) # monkey patch away login to avoid that we actually login # and the UI changes because of that review_app.login = lambda: True # run the main app review_app.run() self._p() review_app.login_successful('foobar') self._p() self.assertEqual(_('Rating:'), review_app.rating_label.get_label()) self.assertEqual(_('Summary:'), review_app.review_summary_label.get_label()) self.assertEqual( _('Review by: %s') % 'foobar', review_app.review_label.get_label()) review_app.submit_window.hide()
def test_change_status(self): review_app = SubmitReviewsApp(datadir="../data", app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='nothing') msg = 'Something completely different' cases = { 'clear': (True, True, True, True, None, None), 'progress': (False, True, True, True, msg, None), 'fail': (True, False, True, True, None, msg), 'success': (True, True, False, True, msg, None), 'warning': (True, True, True, False, msg, None), } review_app.run() for status in cases: review_app._change_status(status, msg) spinner, error, success, warn, label, error_detail = cases[status] self.assertEqual(spinner, review_app.submit_spinner.get_parent() is None) self.assertEqual(error, review_app.submit_error_img.get_window() is None) self.assertEqual( success, review_app.submit_success_img.get_window() is None) self.assertEqual(warn, review_app.submit_warn_img.get_window() is None) if label: self.assertEqual(label, review_app.label_transmit_status.get_text()) if error_detail: buff = review_app.error_textview.get_buffer() self.assertEqual( error_detail, buff.get_text(buff.get_start_iter(), buff.get_end_iter(), include_hidden_chars=False)) review_app.detail_expander.get_visible()
def test_edit_review_screen_has_right_labels(self): """Check that LP #880255 stays fixed. """ review_app = SubmitReviewsApp(datadir="../data", app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='modify', review_id=10000) # monkey patch away login to avoid that we actually login # and the UI changes because of that review_app.login = lambda: True # run the main app review_app.run() self._p() review_app.login_successful('foobar') self._p() self.assertEqual(_('Rating:'), review_app.rating_label.get_label()) self.assertEqual(_('Summary:'), review_app.review_summary_label.get_label()) self.assertEqual(_('Review by: %s') % 'foobar', review_app.review_label.get_label()) review_app.submit_window.hide()
options.parent_xid = options.parent_xid or '1' if not (options.pkgname and options.version): parser.error(_("Missing arguments")) if options.debug: logging.basicConfig(level=logging.DEBUG) # personality logging.debug("submit_review mode") # initialize and run theapp = Application(options.appname, options.pkgname) review_app = SubmitReviewsApp(datadir=options.datadir, app=theapp, parent_xid=options.parent_xid, iconname=options.iconname, origin=options.origin, version=options.version) review_app.run() # run "report" personality if "report_review" in sys.argv[0]: # check options parser.add_option("", "--review-id") parser.add_option("", "--parent-xid") parser.add_option("", "--debug", action="store_true", default=False) (options, args) = parser.parse_args() softwarecenter.paths.datadir = options.datadir if not (options.review_id):
options.parent_xid = options.parent_xid or '1' if not (options.pkgname and options.version): parser.error(_("Missing arguments")) if options.debug: logging.basicConfig(level=logging.DEBUG) # personality logging.debug("submit_review mode") # initialize and run theapp = Application(options.appname, options.pkgname) review_app = SubmitReviewsApp(datadir=options.datadir, app=theapp, parent_xid=options.parent_xid, iconname=options.iconname, origin=options.origin, version=options.version) review_app.run() # run "report" personality if "report_review" in sys.argv[0]: # check options parser.add_option("", "--review-id") parser.add_option("", "--parent-xid") parser.add_option("", "--debug", action="store_true", default=False) (options, args) = parser.parse_args() softwarecenter.paths.datadir = options.datadir