Skip to content

Commit

Permalink
fixed tests and fixed migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
DraKen0009 committed Dec 5, 2024
1 parent 354d69f commit fdab831
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
6 changes: 3 additions & 3 deletions camera/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.2 on 2024-11-21 09:35
# Generated by Django 5.1.3 on 2024-12-05 21:12

import care.utils.models.validators
import django.db.models.deletion
Expand All @@ -22,12 +22,12 @@ class Migration(migrations.Migration):
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('external_id', models.UUIDField(db_index=True, default=uuid.uuid4, unique=True)),
('created_date', models.DateTimeField(auto_now_add=True, db_index=True, null=True)),
('modified_date', models.DateTimeField(auto_now=True, db_index=True, null=True)),
('deleted', models.BooleanField(db_index=True, default=False)),
('name', models.CharField(max_length=255, null=True)),
('position', models.JSONField(validators=[care.utils.models.validators.JSONFieldSchemaValidator({'$schema': 'http://json-schema.org/draft-07/schema#', 'additionalProperties': False, 'properties': {'x': {'type': 'number'}, 'y': {'type': 'number'}, 'zoom': {'type': 'number'}}, 'required': ['x', 'y', 'zoom'], 'type': 'object'})])),
('is_migrated', models.BooleanField(default=False)),
('created_date', models.DateTimeField()),
('modified_date', models.DateTimeField()),
('asset_bed', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='camera_position_presets', to='facility.assetbed')),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Generated by Django 5.1.2 on 2024-11-21 09:35
# Generated by Django 5.1.3 on 2024-12-05 21:12

from django.db import migrations


def migrate_camera_preset_to_position_preset(apps, schema_editor):
try:
CameraPreset = apps.get_model("facility", "CameraPreset")
Expand All @@ -23,6 +22,8 @@ def migrate_camera_preset_to_position_preset(apps, schema_editor):
created_by=preset.created_by,
updated_by=preset.updated_by,
is_migrated=preset.is_migrated,
created_date=preset.created_date,
modified_date=preset.modified_date
)
for preset in camera_presets
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.1.3 on 2024-12-05 21:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('camera', '0002_auto_20241206_0242'),
]

operations = [
migrations.AlterField(
model_name='positionpreset',
name='created_date',
field=models.DateTimeField(auto_now_add=True, db_index=True, null=True),
),
migrations.AlterField(
model_name='positionpreset',
name='modified_date',
field=models.DateTimeField(auto_now=True, db_index=True, null=True),
),
]
5 changes: 5 additions & 0 deletions camera/tests/test_camera_preset_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from care.utils.tests.test_utils import TestUtils
from rest_framework.test import APITestCase
from rest_framework import status
from rest_framework.exceptions import ValidationError
from camera.utils.onvif import OnvifAsset


Expand Down Expand Up @@ -33,6 +34,10 @@ def setUpTestData(cls):
def get_base_url(self, asset_bed_id=None):
return f"/api/camera/position-presets/?assetbed_external_id={asset_bed_id or self.asset_bed1.external_id}"

def validate_invalid_meta(self, asset_class, meta):
with self.assertRaises(ValidationError):
asset_class(meta)

def test_create_camera_preset_without_position(self):
res = self.client.post(
self.get_base_url(),
Expand Down

0 comments on commit fdab831

Please sign in to comment.