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


Python Target.refresh_from_db方法代码示例

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


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

示例1: test_put_one

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import refresh_from_db [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_change_autonomous

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import refresh_from_db [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

示例3: test_put_location

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

        data = {'latitude': 38, 'longitude': -76}

        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(38, t.location.latitude)
        self.assertEqual(-76, t.location.longitude)
开发者ID:legonigel,项目名称:interop,代码行数:17,代码来源:targets_test.py

示例4: test_put_clear_shape

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import refresh_from_db [as 别名]
    def test_put_clear_shape(self):
        """PUT clear a field with None."""
        t = Target(user=self.user,
                   target_type=TargetType.standard,
                   shape=Shape.square)
        t.save()

        data = {'shape': None}

        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(None, t.shape)
开发者ID:legonigel,项目名称:interop,代码行数:18,代码来源:targets_test.py

示例5: test_put_clear_location

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import refresh_from_db [as 别名]
    def test_put_clear_location(self):
        """PUT clear location by clearing lat and lon."""
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()

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

        data = {'latitude': None, 'longitude': None}

        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(None, t.location)
开发者ID:legonigel,项目名称:interop,代码行数:19,代码来源:targets_test.py

示例6: test_put_append

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import refresh_from_db [as 别名]
    def test_put_append(self):
        """PUT sets a new field that wasn't set before."""
        t = Target(user=self.user, target_type=TargetType.standard)
        t.save()

        data = {'description': 'Hello'}

        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('Hello', t.description)

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

示例7: test_put_review

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

        response = self.client.put(
            targets_review_id_url(args=[target.pk]),
            data=json.dumps({'thumbnail_approved': False}))
        self.assertEqual(200, response.status_code)
        data = json.loads(response.content)
        self.assertIn('id', data)
        self.assertEqual(target.pk, data['id'])
        self.assertIn('thumbnail_approved', data)
        self.assertFalse(data['thumbnail_approved'])

        target.refresh_from_db()
        self.assertFalse(target.thumbnail_approved)
开发者ID:auvsi-suas,项目名称:interop,代码行数:19,代码来源:targets_test.py

示例8: test_put_update_location

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import refresh_from_db [as 别名]
    def test_put_update_location(self):
        """PUT updating location only requires one of lat/lon."""
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()

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

        data = {'latitude': 39}

        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(39, t.location.latitude)
        self.assertEqual(-76, t.location.longitude)
开发者ID:legonigel,项目名称:interop,代码行数:21,代码来源:targets_test.py

示例9: test_delete_thumb

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

        pk = t.pk

        with open(test_image("A.jpg")) as f:
            response = self.client.post(
                targets_id_image_url(args=[pk]),
                data=f.read(),
                content_type="image/jpeg")
            self.assertEqual(200, response.status_code)

        t.refresh_from_db()
        thumb = t.thumbnail.path
        self.assertTrue(os.path.exists(thumb))

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

        self.assertFalse(os.path.exists(thumb))
开发者ID:legonigel,项目名称:interop,代码行数:24,代码来源:targets_test.py

示例10: test_put_superuser_change_actionable_override

# 需要导入模块: from auvsi_suas.models.target import Target [as 别名]
# 或者: from auvsi_suas.models.target.Target import refresh_from_db [as 别名]
    def test_put_superuser_change_actionable_override(self):
        """Admin user can update actionable_override flag."""
        # Login as superuser.
        superuser = User.objects.create_superuser(
            'testsuperuser', '[email protected]', 'testsuperpass')
        response = self.client.post(login_url, {
            'username': 'testsuperuser',
            'password': 'testsuperpass'
        })
        self.assertEqual(200, response.status_code)

        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(200, response.status_code)

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


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