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


Python InheritedModel.save方法代码示例

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


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

示例1: AbstractBaseClassTests

# 需要导入模块: from test_project.apps.testapp.models import InheritedModel [as 别名]
# 或者: from test_project.apps.testapp.models.InheritedModel import save [as 别名]
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,代码行数:43,代码来源:tests.py

示例2: AbstractBaseClassTests

# 需要导入模块: from test_project.apps.testapp.models import InheritedModel [as 别名]
# 或者: from test_project.apps.testapp.models.InheritedModel import save [as 别名]
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,代码行数:42,代码来源:tests.py


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