Пример #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_max_pace_should_not_accept_negative_value(self):
     sport = Sport()
     try:
         sport.max_pace = -1
     except(ValueError):
         pass
     else:
         self.fail()
Пример #3
0
 def test_max_pace_should_not_accept_non_integer_string(self):
     sport = Sport()
     try:
         sport.max_pace = "225s"
     except(ValueError):
         pass
     else:
         self.fail()
Пример #4
0
 def test_max_pace_should_not_accept_negative_value(self):
     sport = Sport()
     try:
         sport.max_pace = -1
     except (ValueError):
         pass
     else:
         self.fail()
Пример #5
0
 def test_max_pace_should_not_accept_non_integer_string(self):
     sport = Sport()
     try:
         sport.max_pace = "225s"
     except (ValueError):
         pass
     else:
         self.fail()
Пример #6
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()
Пример #7
0
 def test_max_pace_should_accept_none(self):
     sport = Sport()
     sport.max_pace = None
     self.assertEquals(None, sport.max_pace)
Пример #8
0
 def test_max_pace_should_take_floor_of_float(self):
     sport = Sport()
     sport.max_pace = 220.6
     self.assertEquals(220, sport.max_pace)
Пример #9
0
 def test_max_pace_should_accept_integer_string(self):
     sport = Sport()
     sport.max_pace = "220"
     self.assertEquals(220, sport.max_pace)
Пример #10
0
 def test_max_pace_should_accept_integer(self):
     sport = Sport()
     sport.max_pace = 220
     self.assertEquals(220, sport.max_pace)
Пример #11
0
 def test_max_pace_should_accept_none(self):
     sport = Sport()
     sport.max_pace = None
     self.assertEquals(None, sport.max_pace)
Пример #12
0
 def test_max_pace_should_take_floor_of_float(self):
     sport = Sport()
     sport.max_pace = 220.6
     self.assertEquals(220, sport.max_pace)
Пример #13
0
 def test_max_pace_should_accept_integer_string(self):
     sport = Sport()
     sport.max_pace = "220"
     self.assertEquals(220, sport.max_pace)
Пример #14
0
 def test_max_pace_should_accept_integer(self):
     sport = Sport()
     sport.max_pace = 220
     self.assertEquals(220, sport.max_pace)