當前位置: 首頁>>代碼示例>>Python>>正文


Python target.Target類代碼示例

本文整理匯總了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)
開發者ID:legonigel,項目名稱:interop,代碼行數:35,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:7,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:9,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:9,代碼來源:targets_test.py

示例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))
開發者ID:legonigel,項目名稱:interop,代碼行數:9,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:11,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:11,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:12,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:13,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:13,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:14,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:14,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:14,代碼來源:targets_test.py

示例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)
開發者ID:legonigel,項目名稱:interop,代碼行數:15,代碼來源:targets_test.py

示例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))
開發者ID:legonigel,項目名稱:interop,代碼行數:15,代碼來源:targets_test.py


注:本文中的auvsi_suas.models.target.Target類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。