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


Python models.InheritedModel類代碼示例

本文整理匯總了Python中test_project.apps.testapp.models.InheritedModel的典型用法代碼示例。如果您正苦於以下問題:Python InheritedModel類的具體用法?Python InheritedModel怎麽用?Python InheritedModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: AbstractBaseClassTests

class AbstractBaseClassTests(MainTests):
    def init_delegate(self):
        self.ab1 = InheritedModel()
        self.ab1.save()
        self.ab2 = InheritedModel()
        self.ab2.save()

    def test_field_presence(self):
        result = self.client.get('/api/abstract.json',
                HTTP_AUTHORIZATION=self.auth_string).content

        expected = """[
    {
        "id": 1,
        "some_other": "something else",
        "some_field": "something here"
    },
    {
        "id": 2,
        "some_other": "something else",
        "some_field": "something here"
    }
]"""

        self.assertEquals(result, expected)

    def test_specific_id(self):
        ids = (1, 2)
        be = """{
    "id": %d,
    "some_other": "something else",
    "some_field": "something here"
}"""

        for id_ in ids:
            result = self.client.get('/api/abstract/%d.json' % id_,
                    HTTP_AUTHORIZATION=self.auth_string).content

            expected = be % id_

            self.assertEquals(result, expected)
開發者ID:habeanf,項目名稱:django-piston,代碼行數:41,代碼來源:tests.py

示例2: AbstractBaseClassTests

class AbstractBaseClassTests(MainTests):
    def init_delegate(self):
        self.ab1 = InheritedModel()
        self.ab1.save()
        self.ab2 = InheritedModel()
        self.ab2.save()
        
    def test_field_presence(self):
        result = self.client.get('/api/abstract.json',
                HTTP_AUTHORIZATION=self.auth_string).content
                
        expected = [
          {
              "id": 1,
              "some_other": "something else",
              "some_field": "something here"
          },
          {
              "id": 2,
              "some_other": "something else",
              "some_field": "something here"
          }
        ]
        
        self.assertEqual(json.loads(result.decode('utf-8')), expected)

    def test_specific_id(self):
        ids = (1, 2)
        expected = {
          "some_other": "something else",
          "some_field": "something here"
          }
        
        for id_ in ids:
            result = self.client.get('/api/abstract/%d.json' % id_,
                    HTTP_AUTHORIZATION=self.auth_string).content
                    
            expected['id'] = id_
            
            self.assertEqual(json.loads(result.decode('utf-8')), expected)
開發者ID:userzimmermann,項目名稱:django-piston3,代碼行數:40,代碼來源:tests.py

示例3: init_delegate

 def init_delegate(self):
     self.ab1 = InheritedModel()
     self.ab1.save()
     self.ab2 = InheritedModel()
     self.ab2.save()
開發者ID:habeanf,項目名稱:django-piston,代碼行數:5,代碼來源:tests.py


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