예제 #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)