本文整理汇总了Python中auvsi_suas.models.target.Target类的典型用法代码示例。如果您正苦于以下问题:Python Target类的具体用法?Python Target怎么用?Python Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_put_one
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)
示例2: test_put_review_no_approved
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)
示例3: test_get_other_user
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)
示例4: test_delete_other
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)
示例5: test_get_own
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))
示例6: test_put_location_missing_one
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)
示例7: test_put_change_actionable_override
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)
示例8: test_get_after_delete_own
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)
示例9: test_put_clear_type
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)
示例10: test_put_invalid_json
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)
示例11: test_put_partial_clear_location
def test_put_partial_clear_location(self):
"""PUT can't clear location with only 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': None}
response = self.client.put(
targets_id_url(args=[t.pk]),
data=json.dumps(data))
self.assertEqual(400, response.status_code)
示例12: test_delete_own
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)
示例13: test_put_change_autonomous
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)
示例14: test_put_location
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)
示例15: test_get_noneditable_without_thumbnail_targets
def test_get_noneditable_without_thumbnail_targets(self):
"""Test GET when there are non-editable targets without thumbnail."""
MissionClockEvent(user=self.team,
team_on_clock=True,
team_on_timeout=False).save()
MissionClockEvent(user=self.team,
team_on_clock=False,
team_on_timeout=False).save()
target = Target(user=self.team, target_type=TargetType.standard)
target.save()
response = self.client.get(targets_review_url)
self.assertEqual(200, response.status_code)
data = json.loads(response.content)
self.assertEqual(0, len(data))