本文整理汇总了Python中pytrainer.core.sport.Sport类的典型用法代码示例。如果您正苦于以下问题:Python Sport类的具体用法?Python Sport怎么用?Python Sport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_sport_should_remove_associated_entries
def test_remove_sport_should_remove_associated_entries(self):
sport = Sport()
sport.name = u"Test name"
sport = self.sport_service.store_sport(sport)
self.sport_service.remove_sport(sport)
result = self.sport_service.get_sport(1)
self.assertEqual(result, None)
示例2: test_max_pace_should_take_floor_of_float
def test_max_pace_should_take_floor_of_float(self):
sport = Sport()
sport.max_pace = 220.6
self.ddbb.session.add(sport)
self.ddbb.session.commit()
sport = self.ddbb.session.query(Sport).filter(Sport.id == 1).one()
self.assertEqual(220, sport.max_pace)
示例3: test_id_should_accept_integer_string
def test_id_should_accept_integer_string(self):
sport = Sport()
sport.id = "1"
self.ddbb.session.add(sport)
self.ddbb.session.commit()
sport = self.ddbb.session.query(Sport).filter(Sport.id == 1).one()
self.assertEqual(1, sport.id)
示例4: test_met_should_not_accept_non_float_string
def test_met_should_not_accept_non_float_string(self):
sport = Sport()
try:
sport.met = "22.5kg"
except(ValueError):
pass
else:
self.fail()
示例5: test_met_should_accept_float_string
def test_met_should_accept_float_string(self):
sport = Sport()
sport.name = "test1"
sport.met = "22.5"
self.ddbb.session.add(sport)
self.ddbb.session.commit()
sport = self.ddbb.session.query(Sport).filter(Sport.id == 1).one()
self.assertEqual(22.5, sport.met)
示例6: test_max_pace_should_not_accept_non_integer_string
def test_max_pace_should_not_accept_non_integer_string(self):
sport = Sport()
try:
sport.max_pace = "225s"
except(ValueError):
pass
else:
self.fail()
示例7: test_max_pace_should_not_accept_negative_value
def test_max_pace_should_not_accept_negative_value(self):
sport = Sport()
try:
sport.max_pace = -1
except(ValueError):
pass
else:
self.fail()
示例8: test_name_should_not_accept_non_unicode_string
def test_name_should_not_accept_non_unicode_string(self):
sport = Sport()
try:
sport.name = "Juggling"
except(TypeError):
pass
else:
self.fail()
示例9: test_id_should_not_accept_non_integer_string
def test_id_should_not_accept_non_integer_string(self):
sport = Sport()
try:
sport.id = "1.1"
except(ValueError):
pass
else:
self.fail()
示例10: test_name_should_not_accept_none
def test_name_should_not_accept_none(self):
sport = Sport()
try:
sport.name = None
except(TypeError):
pass
else:
self.fail()
示例11: test_store_sport_should_update_row_when_sport_has_id
def test_store_sport_should_update_row_when_sport_has_id(self):
sport = Sport()
sport.name = u"Test name"
sport = self.sport_service.store_sport(sport)
sport.name = u"New name"
self.sport_service.store_sport(sport)
sport = self.sport_service.get_sport(1)
self.assertEqual(sport.name, u"New name")
示例12: test_color_should_not_accept_none
def test_color_should_not_accept_none(self):
sport = Sport()
try:
sport.color = None
except(ValueError):
pass
else:
self.fail()
示例13: test_weight_should_not_accept_negative_value
def test_weight_should_not_accept_negative_value(self):
sport = Sport()
try:
sport.weight = -1
except(ValueError):
pass
else:
self.fail()
示例14: test_remove_sport_should_error_when_sport_has_unknown_id
def test_remove_sport_should_error_when_sport_has_unknown_id(self):
sport = Sport()
sport.id = 100
try:
self.sport_service.remove_sport(sport)
except(SportServiceException):
pass
else:
self.fail()
示例15: test_name_should_not_accept_none
def test_name_should_not_accept_none(self):
sport = Sport()
sport.name = None
try:
self.ddbb.session.add(sport)
self.ddbb.session.commit()
except (IntegrityError, OperationalError):
pass
else:
self.fail()