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


Python Target.save方法代码示例

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


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

示例1: test_put_one

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_put_one(self):
        """PUT update one field without affecting others."""
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()

        t = Target(user=self.user,
                   target_type=TargetType.standard,
                   location=l,
                   orientation=Orientation.s,
                   shape=Shape.square,
                   background_color=Color.white,
                   alphanumeric='ABC',
                   alphanumeric_color=Color.black,
                   description='Test target')
        t.save()

        data = {'shape': 'circle'}

        response = self.client.put(
            targets_id_url(args=[t.pk]),
            data=json.dumps(data))
        self.assertEqual(200, response.status_code)

        t.refresh_from_db()
        t.location.refresh_from_db()
        self.assertEqual(self.user, t.user)
        self.assertEqual(TargetType.standard, t.target_type)
        self.assertEqual(38, t.location.latitude)
        self.assertEqual(-76, t.location.longitude)
        self.assertEqual(Orientation.s, t.orientation)
        self.assertEqual(Shape.circle, t.shape)
        self.assertEqual(Color.white, t.background_color)
        self.assertEqual('ABC', t.alphanumeric)
        self.assertEqual(Color.black, t.alphanumeric_color)
        self.assertEqual('Test target', t.description)
开发者ID:legonigel,项目名称:interop,代码行数:37,代码来源:targets_test.py

示例2: test_put_review_no_approved

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_put_review_no_approved(self):
        """Test PUT review with no approved field."""
        target = Target(user=self.team, target_type=TargetType.standard)
        target.save()

        response = self.client.put(targets_review_id_url(args=[target.pk]))
        self.assertEqual(400, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:9,代码来源:targets_test.py

示例3: test_delete_other

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_delete_other(self):
        """Test DELETEing a target owned by another user."""
        user2 = User.objects.create_user('testuser2', '[email protected]',
                                         'testpass')
        t = Target(user=user2, target_type=TargetType.standard)
        t.save()

        response = self.client.delete(targets_id_url(args=[t.pk]))
        self.assertEqual(403, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:11,代码来源:targets_test.py

示例4: test_get_own

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_get_own(self):
        """Test GETting a target owned by the correct user."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        response = self.client.get(targets_id_url(args=[t.pk]))
        self.assertEqual(200, response.status_code)

        self.assertEqual(t.json(), json.loads(response.content))
开发者ID:legonigel,项目名称:interop,代码行数:11,代码来源:targets_test.py

示例5: test_get_other_user

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_get_other_user(self):
        """Test GETting a thumbnail owned by a different user."""
        user2 = User.objects.create_user('testuser2', '[email protected]',
                                         'testpass')
        t = Target(user=user2, target_type=TargetType.standard)
        t.save()

        response = self.client.get(targets_id_image_url(args=[t.pk]))
        self.assertEqual(403, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:11,代码来源:targets_test.py

示例6: test_put_change_actionable_override

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_put_change_actionable_override(self):
        """PUT fails if non-admin user tries to change actionable_override."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        data = {'actionable_override': True}

        response = self.client.put(
            targets_id_url(args=[t.pk]),
            data=json.dumps(data))
        self.assertEqual(403, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:13,代码来源:targets_test.py

示例7: test_put_location_missing_one

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_put_location_missing_one(self):
        """PUTting new location requires both latitude and longitude."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        data = {'latitude': 38}

        response = self.client.put(
            targets_id_url(args=[t.pk]),
            data=json.dumps(data))
        self.assertEqual(400, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:13,代码来源:targets_test.py

示例8: test_get_after_delete_own

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_get_after_delete_own(self):
        """Test GETting a target after DELETE."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        pk = t.pk

        response = self.client.delete(targets_id_url(args=[pk]))
        self.assertEqual(200, response.status_code)

        response = self.client.get(targets_id_url(args=[pk]))
        self.assertEqual(404, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:14,代码来源:targets_test.py

示例9: test_creation_time

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_creation_time(self):
        """Creation time is set on creation and doesn't change on update."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        orig = t.creation_time
        self.assertIsNotNone(orig)

        t.alphanumeric = 'A'
        t.save()

        self.assertEqual(orig, t.creation_time)
开发者ID:auvsi-suas,项目名称:interop,代码行数:14,代码来源:target_test.py

示例10: test_last_modified_time

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_last_modified_time(self):
        """Last modified time is set on creation and changes every update."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        orig = t.last_modified_time
        self.assertIsNotNone(orig)

        t.alphanumeric = 'A'
        t.save()

        self.assertGreater(t.last_modified_time, orig)
开发者ID:auvsi-suas,项目名称:interop,代码行数:14,代码来源:target_test.py

示例11: test_put_clear_type

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_put_clear_type(self):
        """PUT type may not be cleared."""
        t = Target(user=self.user,
                   target_type=TargetType.standard,
                   shape=Shape.square)
        t.save()

        data = {'type': None}

        response = self.client.put(
            targets_id_url(args=[t.pk]),
            data=json.dumps(data))
        self.assertEqual(400, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:15,代码来源:targets_test.py

示例12: test_put_invalid_json

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_put_invalid_json(self):
        """PUT request body must be valid JSON."""
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()

        t = Target(user=self.user, target_type=TargetType.standard, location=l)
        t.save()

        response = self.client.put(
            targets_id_url(args=[t.pk]),
            data="latitude=76",
            content_type='multipart/form-data')
        self.assertEqual(400, response.status_code)
开发者ID:legonigel,项目名称:interop,代码行数:15,代码来源:targets_test.py

示例13: test_delete_own

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_delete_own(self):
        """Test DELETEing a target owned by the correct user."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        pk = t.pk

        self.assertTrue(Target.objects.get(pk=pk))

        response = self.client.delete(targets_id_url(args=[pk]))
        self.assertEqual(200, response.status_code)

        with self.assertRaises(Target.DoesNotExist):
            Target.objects.get(pk=pk)
开发者ID:legonigel,项目名称:interop,代码行数:16,代码来源:targets_test.py

示例14: test_get_targets

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_get_targets(self):
        """We get back the targets we own."""
        t1 = Target(user=self.user, target_type=TargetType.standard)
        t1.save()

        t2 = Target(user=self.user, target_type=TargetType.standard)
        t2.save()

        response = self.client.get(targets_url)
        self.assertEqual(200, response.status_code)

        d = json.loads(response.content)

        self.assertItemsEqual([t1.json(), t2.json()], d)
开发者ID:legonigel,项目名称:interop,代码行数:16,代码来源:targets_test.py

示例15: test_put_change_autonomous

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import save [as 别名]
    def test_put_change_autonomous(self):
        """Change autonomous with PUT"""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        data = {'autonomous': True}

        response = self.client.put(
            targets_id_url(args=[t.pk]),
            data=json.dumps(data))
        self.assertEqual(200, response.status_code)

        t.refresh_from_db()
        self.assertEqual(True, t.autonomous)
开发者ID:legonigel,项目名称:interop,代码行数:16,代码来源:targets_test.py


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