當前位置: 首頁>>代碼示例>>Python>>正文


Python Entity.active_member方法代碼示例

本文整理匯總了Python中mhvdb2.models.Entity.active_member方法的典型用法代碼示例。如果您正苦於以下問題:Python Entity.active_member方法的具體用法?Python Entity.active_member怎麽用?Python Entity.active_member使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mhvdb2.models.Entity的用法示例。


在下文中一共展示了Entity.active_member方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MembersTestCases

# 需要導入模塊: from mhvdb2.models import Entity [as 別名]
# 或者: from mhvdb2.models.Entity import active_member [as 別名]

#.........這裏部分代碼省略.........
        errors = members.validate(self.test_member.name,
                                  self.test_member.email,
                                  self.test_member.phone,
                                  "2014-12-25",
                                  self.agreement_date,
                                  self.test_member.is_keyholder)
        self.assertEqual(len(errors), 0)

        errors = members.validate(self.test_member.name,
                                  self.test_member.email,
                                  self.test_member.phone,
                                  "The 25th of December, Stardate 21020",
                                  self.agreement_date,
                                  self.test_member.is_keyholder)
        self.assertEqual(len(errors), 1)

    def test_validate_agreement_date(self):
        errors = members.validate(self.test_member.name,
                                  self.test_member.email,
                                  self.test_member.phone,
                                  self.joined_date,
                                  "2014-12-25",
                                  self.test_member.is_keyholder)
        self.assertEqual(len(errors), 0)

        errors = members.validate(self.test_member.name,
                                  self.test_member.email,
                                  self.test_member.phone,
                                  "The 25th of December, Stardate 21020",
                                  self.agreement_date,
                                  self.test_member.is_keyholder)
        self.assertEqual(len(errors), 1)

    def test_active_member(self):

        self.assertTrue(self.test_member.active_member(),
                        'member agreement is current')
        new_agreement_date = date.today()-timedelta(days=500)
        members.update(self.test_member.id,
                       self.test_member.name,
                       self.test_member.email,
                       self.test_member.phone,
                       self.test_member.joined_date,
                       new_agreement_date,
                       self.test_member.is_keyholder)
        member = Entity.get(Entity.id == self.test_member.id)
        self.assertFalse(member.active_member(), 'member agreement not current')

    def test_create(self):
        member_id = members.create(self.test_member.name,
                                   self.test_member.email,
                                   self.test_member.phone,
                                   self.test_member.joined_date,
                                   self.test_member.agreement_date,
                                   self.test_member.is_keyholder)
        member = Entity.get(Entity.id == member_id)

        self.assertNotEqual(member.id, self.test_member.id)
        self.assertEqual(member.name, self.test_member.name)
        self.assertEqual(member.email, self.test_member.email)
        self.assertEqual(member.phone, self.test_member.phone)
        self.assertEqual(member.joined_date, self.test_member.joined_date)
        self.assertEqual(member.agreement_date, self.test_member.agreement_date)
        self.assertEqual(member.is_keyholder, self.test_member.is_keyholder)
        member.delete_instance()
開發者ID:kdmurray91,項目名稱:mhvdb2,代碼行數:69,代碼來源:test_members.py


注:本文中的mhvdb2.models.Entity.active_member方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。