Пример #1
0
 def on_newsport_accept_clicked(self, widget):
     sport = Sport()
     sport.name = unicode(self.newsportentry.get_text())
     sport.met = self._trim_to_null(self.newmetentry.get_text())
     sport.weight = self.newweightentry.get_text()
     sport.max_pace = self._trim_to_null(self.newmaxpace.get_text())
     sport.color = self.stored_color
     if sport.name.lower() in [
             s.name.lower() for s in self._sport_service.get_all_sports()
     ]:
         msg = "Sport '%s' already exists" % sport.name
         logging.error(msg)
         md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
                                gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
                                _(msg))
         md.set_title(_("Sport Creation Error"))
         md.run()
         md.destroy()
         return
     self._sport_service.store_sport(sport)
     self.parent.actualize_mainsportlist()
     self.on_switch_page(None, None, 2)
     self.hidesportsteps()
     self.buttonbox.set_sensitive(1)
     self.sportlist.show()
Пример #2
0
 def test_weight_should_not_accept_none(self):
     sport = Sport()
     try:
         sport.weight = None
     except(TypeError):
         pass
     else:
         self.fail()
Пример #3
0
 def test_weight_should_not_accept_negative_value(self):
     sport = Sport()
     try:
         sport.weight = -1
     except(ValueError):
         pass
     else:
         self.fail()
Пример #4
0
 def test_weight_should_not_accept_non_float_string(self):
     sport = Sport()
     try:
         sport.weight = "22.5kg"
     except(ValueError):
         pass
     else:
         self.fail()
Пример #5
0
 def test_weight_should_not_accept_none(self):
     sport = Sport()
     try:
         sport.weight = None
     except (TypeError):
         pass
     else:
         self.fail()
Пример #6
0
 def test_weight_should_not_accept_negative_value(self):
     sport = Sport()
     try:
         sport.weight = -1
     except (ValueError):
         pass
     else:
         self.fail()
Пример #7
0
 def test_weight_should_not_accept_non_float_string(self):
     sport = Sport()
     try:
         sport.weight = "22.5kg"
     except (ValueError):
         pass
     else:
         self.fail()
Пример #8
0
 def on_newsport_accept_clicked(self,widget):
     sport = Sport()
     sport.name = unicode(self.newsportentry.get_text())
     sport.met = self._trim_to_null(self.newmetentry.get_text())
     sport.weight = self.newweightentry.get_text()
     sport.max_pace = self._trim_to_null(self.newmaxpace.get_text())
     sport.color = self.stored_color
     if sport.name.lower() in [s.name.lower() for s in self._sport_service.get_all_sports()]:
         msg = "Sport '%s' already exists" % sport.name
         logging.error(msg)
         md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, _(msg))
         md.set_title(_("Sport Creation Error"))
         md.run()
         md.destroy()
         return
     self._sport_service.store_sport(sport)
     self.parent.actualize_mainsportlist()
     self.on_switch_page(None,None,2)
     self.hidesportsteps()
     self.buttonbox.set_sensitive(1)
     self.sportlist.show()
Пример #9
0
 def test_weight_should_accept_float_string(self):
     sport = Sport()
     sport.weight = "22.5"
     self.assertEquals(22.5, sport.weight)
Пример #10
0
 def test_weight_should_accept_float(self):
     sport = Sport()
     sport.weight = 22.5
     self.assertEquals(22.5, sport.weight)
Пример #11
0
 def test_weight_should_accept_float_string(self):
     sport = Sport()
     sport.weight = "22.5"
     self.assertEquals(22.5, sport.weight)
Пример #12
0
 def test_weight_should_accept_float(self):
     sport = Sport()
     sport.weight = 22.5
     self.assertEquals(22.5, sport.weight)