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


Python Sport.name方法代码示例

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


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

示例1: test_store_sport_should_update_row_when_sport_has_id

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

示例2: test_store_sport_should_error_when_new_sport_has_duplicate_name

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import name [as 别名]
 def test_store_sport_should_error_when_new_sport_has_duplicate_name(self):
     sport1 = Sport()
     sport1.name = u"Test name"
     self.sport_service.store_sport(sport1)
     sport2 = Sport()
     sport2.name = u"Test name"
     try:
         self.sport_service.store_sport(sport2)
     except(SportServiceException):
         pass
     else:
         self.fail()
开发者ID:pytrainer,项目名称:pytrainer,代码行数:14,代码来源:test_sport.py

示例3: test_get_all_sports_should_return_all_sports_in_query_result

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import name [as 别名]
 def test_get_all_sports_should_return_all_sports_in_query_result(self):
     sport1 = Sport()
     sport1.name = u"Test name"
     self.sport_service.store_sport(sport1)
     sport2 = Sport()
     sport2.name = u"Test name 2"
     self.sport_service.store_sport(sport2)
     sports = self.sport_service.get_all_sports()
     self.assertEqual(2, len(sports))
     sport1 = sports[0]
     self.assertEqual(1, sport1.id)
     sport2 = sports[1]
     self.assertEqual(2, sport2.id)
开发者ID:pytrainer,项目名称:pytrainer,代码行数:15,代码来源:test_sport.py

示例4: test_remove_sport_should_remove_associated_entries

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

示例5: test_name_should_not_accept_non_unicode_string

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

示例6: test_name_should_not_accept_none

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

示例7: test_met_should_accept_float_string

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

示例8: test_name_should_not_accept_none

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

示例9: test_store_sport_should_error_when_new_sport_has_duplicate_name

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import name [as 别名]
 def test_store_sport_should_error_when_new_sport_has_duplicate_name(self):
     self.mock_ddbb.select.return_value = [(1, u"Test name", 150, 12.5, 200, "0")]
     sport = Sport()
     sport.name = u"Test name"
     try:
         self.sport_service.store_sport(sport)
     except(SportServiceException):
         pass
     else:
         self.fail()
开发者ID:MrBricodage,项目名称:pytrainer,代码行数:12,代码来源:sport_test.py

示例10: test_name_should_not_accept_non_unicode_string

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

示例11: test_store_sport_should_insert_row_when_sport_has_no_id

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

示例12: test_store_sport_should_update_row_when_sport_has_id

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import name [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

示例13: test_store_sport_should_error_when_existing_sport_has_duplicate_name

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import name [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

示例14: getSportId

# 需要导入模块: from pytrainer.core.sport import Sport [as 别名]
# 或者: from pytrainer.core.sport.Sport import name [as 别名]
    def getSportId(self, sport_name, add=None):
        """Deprecated: use sport_service.get_sport_by_name()
		
		Get the id of a sport by name, optionally adding a new sport if
		none exists with the given name.
		arguments:
			sport_name: sport's name to get id for
			add: whether the sport should be added if not found
		returns: id for sport with given name or None"""
        if sport_name is None:
            return None
        sport = self._get_sport(sport_name)
        if sport is None:
            logging.debug("No sport with name: '%s'", str(sport_name))
            if add is not None:
                logging.debug("Adding sport '%s'", str(sport_name))
                new_sport = Sport()
                new_sport.name = unicode(sport_name)
                sport = self._sport_service.store_sport(new_sport)
        return None if sport is None else sport.id
开发者ID:rgonzalez72,项目名称:pytrainer,代码行数:22,代码来源:record.py

示例15: on_newsport_accept_clicked

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


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