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


Python Item.user方法代码示例

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


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

示例1: setUp

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import user [as 别名]
    def setUp(self):
        super(ItemApiTest, self).setUp()

        # Create a user.
        self.username = 'test_user'
        self.password = 'test_pass'
        self.user = User.objects.create_user(self.username, '[email protected]', self.password)
        
        # Create another user
        self.username2 = 'test_user2'
        self.password2 = 'test_pass2'
        self.user2 = User.objects.create_user(self.username2, '[email protected]', self.password2)

        item = Item()
        item.name = "Test Item #1"
        item.user = self.user
        item.notes = "testing..."
        item.save()
        self.item = item

        # Build a URI for the item
        self.detail_uri = '/api/v1/todo/{0}/'.format(self.item.pk)
        
        # ...as well as a URI to list all items
        self.list_uri = '/api/v1/todo/'

        # ...and URIs for each user
        self.user_uri = '/api/v1/user/{0}/'.format(self.user.pk)
        self.user2_uri = '/api/v1/user/{0}/'.format(self.user2.pk)

        # The data we'll send on POST requests.
        self.post_data = {
            'user': self.user_uri,
            'name': 'Test Item #2'
        }
        
        self.post_data2 = {
            'user': self.user2_uri,
            'name': 'Test Item #3'
        }
        

        # Expected test item JSON from server
        self.test_item_json = {
            'name': 'Test Item #1',
            'created': str(self.item.created),
            'notes': 'testing...',
            'due': None,
            'priority': 0,
            'done': False,
            'user': self.user_uri,
            'id': str(self.item.pk),
            'resource_uri': self.detail_uri 
        }
开发者ID:varunnaik,项目名称:Django-Test-Todolist,代码行数:56,代码来源:tests.py

示例2: test_todo_item

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import user [as 别名]
 def test_todo_item(self):
     """Tests the todo item model"""
     # Does validation fail on an invalid item?
     item = Item()
     validatedSuccessfully = False
     try:
         item.full_clean()
     except ValidationError:
         validatedSuccessfully = True
         
     self.assertEquals(validatedSuccessfully, True)
     
     # Does validation pass on a valid item?
     item.name = "test"
     item.user = self.user
     validatedSuccessfully = True
     try:
         item.full_clean()
     except ValidationError:
         validatedSuccessfully = False
         
     self.assertEquals(validatedSuccessfully, True)
开发者ID:varunnaik,项目名称:Django-Test-Todolist,代码行数:24,代码来源:tests.py


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