def _contract_selected(self, pool, quantity=1): if not valid_quantity(quantity): show_error_window(_("Quantity must be a positive number."), parent=self.parent_win) return self._contract_selection_cancelled() # Start the progress bar self.pb = progress.Progress(_("Attaching"), _("Attaching subscription. Please wait.")) self.timer = ga_GObject.timeout_add(100, self.pb.pulse) self.pb.set_transient_for(self.parent_win) # Spin off a thread to handle binding the selected pool. # After it has completed the actual bind call, available # subs will be refreshed, but we won't re-run compliance # until we have serialized the certificates self.async_bind.bind(pool, quantity, bind_callback=self._async_bind_callback, cert_callback=self.backend.cs.force_cert_check, except_callback=self._async_bind_exception_callback)
def _contract_selected(self, pool, quantity=1): if not valid_quantity(quantity): show_error_window(_("Quantity must be a positive number."), parent=self.parent_win) return self._contract_selection_cancelled() # Start the progress bar self.pb = progress.Progress(_("Attaching"), _("Attaching subscription. Please wait.")) self.timer = ga_GObject.timeout_add(100, self.pb.pulse) self.pb.set_transient_for(self.parent_win) # Spin off a thread to handle binding the selected pool. # After it has completed the actual bind call, available # subs will be refreshed, but we won't re-run compliance # until we have serialized the certificates self.async_bind.bind( pool, quantity, bind_callback=self._async_bind_callback, cert_callback=self.backend.cs.force_cert_check, except_callback=self._async_bind_exception_callback)
def test_string_quantity_not_valid(self): self.assertFalse(valid_quantity("12dfg2"))
def test_positive_quantity_value_is_valid(self): self.assertTrue(valid_quantity(3))
def test_neg_quantity_value_is_invalid(self): self.assertFalse(valid_quantity(-1))
def test_nonetype_not_valid(self): self.assertFalse(valid_quantity(None))