当前位置: 首页>>代码示例>>Python>>正文


Python Sport.id方法代码示例

本文整理汇总了Python中pytrainer.core.sport.Sport.id方法的典型用法代码示例。如果您正苦于以下问题:Python Sport.id方法的具体用法?Python Sport.id怎么用?Python Sport.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytrainer.core.sport.Sport的用法示例。


在下文中一共展示了Sport.id方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_id_should_accept_integer_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 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)
开发者ID:pytrainer,项目名称:pytrainer,代码行数:9,代码来源:test_sport.py

示例2: test_id_should_not_accept_none

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_id_should_not_accept_none(self):
     sport = Sport()
     try:
         sport.id = None
     except(TypeError):
         pass
     else:
         self.fail()
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:10,代码来源:sport_test.py

示例3: test_id_should_not_accept_non_integer_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_id_should_not_accept_non_integer_string(self):
     sport = Sport()
     try:
         sport.id = "1.1"
     except(ValueError):
         pass
     else:
         self.fail()
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:10,代码来源:sport_test.py

示例4: test_remove_sport_should_error_when_sport_has_unknown_id

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 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()
开发者ID:pytrainer,项目名称:pytrainer,代码行数:11,代码来源:test_sport.py

示例5: test_remove_sport_should_remove_associated_entries

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_remove_sport_should_remove_associated_entries(self):
     self.mock_ddbb.select.return_value = [[1]]
     sport = Sport()
     sport.id = 1
     delete_arguments = []
     def mock_delete(*args):
         delete_arguments.append(args) 
     self.mock_ddbb.delete = mock.Mock(wraps=mock_delete)
     self.sport_service.remove_sport(sport)
     self.assertEquals(("records", "sport=1"), delete_arguments[0])
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:12,代码来源:sport_test.py

示例6: test_remove_sport_should_error_when_sport_has_unknown_id

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_remove_sport_should_error_when_sport_has_unknown_id(self):
     self.mock_ddbb.select.return_value = []
     sport = Sport()
     sport.id = 100
     try:
         self.sport_service.remove_sport(sport)
     except(SportServiceException):
         pass
     else:
         self.fail()
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:12,代码来源:sport_test.py

示例7: test_id_should_not_accept_non_integer_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_id_should_not_accept_non_integer_string(self):
     sport = Sport()
     try:
         sport.id = "test"
         self.ddbb.session.add(sport)
         self.ddbb.session.flush()
     except (IntegrityError, DataError, OperationalError):
         pass
     else:
         self.fail()
开发者ID:pytrainer,项目名称:pytrainer,代码行数:12,代码来源:test_sport.py

示例8: test_store_sport_should_update_row_when_sport_has_id

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_store_sport_should_update_row_when_sport_has_id(self):
     def mock_select(table, columns, where):
         if columns == "id_sports":
             return [[1]]
         else:
             return [(1, u"", 0, 0, 0, "0")]
     self.mock_ddbb.select = mock.Mock(wraps=mock_select)
     sport = Sport()
     sport.id = 1
     sport.name = u"New name"
     self.sport_service.store_sport(sport)
     self.mock_ddbb.update.assert_called_with("sports",  "name,weight,met,max_pace,color",
                                              [u"New name", 0.0, None, None, "0000ff"], "id_sports=1")
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:15,代码来源:sport_test.py

示例9: test_store_sport_should_error_when_existing_sport_has_duplicate_name

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_store_sport_should_error_when_existing_sport_has_duplicate_name(self):
     def mock_select(table, columns, where):
         if columns == pytrainer.core.sport._ID_COLUMN:
             return [[2]]
         else:
             return [(1, u"Test name", 0, 0.0, "0"), (2, u"New name", 0, 0.0, "0")]
     self.mock_ddbb.select = mock.Mock(wraps=mock_select)
     sport = Sport()
     sport.id = 1
     sport.name = u"New name"
     try:
         self.sport_service.store_sport(sport)
     except(SportServiceException):
         pass
     else:
         self.fail()
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:18,代码来源:sport_test.py

示例10: test_remove_sport_should_delete_sport_with_specified_id

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_remove_sport_should_delete_sport_with_specified_id(self):
     self.mock_ddbb.select.return_value = [[1]]
     sport = Sport()
     sport.id = 1
     self.sport_service.remove_sport(sport)
     self.mock_ddbb.delete.assert_called_with("sports", "id_sports=1")
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:8,代码来源:sport_test.py

示例11: test_id_should_accept_integer_string

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_id_should_accept_integer_string(self):
     sport = Sport()
     sport.id = "1"
     self.assertEquals(1, sport.id)
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:6,代码来源:sport_test.py

示例12: test_id_should_accept_integer

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import id [as 别名]
 def test_id_should_accept_integer(self):
     sport = Sport()
     sport.id = 1
     self.assertEquals(1, sport.id)
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:6,代码来源:sport_test.py


注:本文中的pytrainer.core.sport.Sport.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。