diff --git a/src/hope_dedup_engine/apps/api/migrations/0001_initial.py b/src/hope_dedup_engine/apps/api/migrations/0001_initial.py index d4d09d12..9a1a30a3 100644 --- a/src/hope_dedup_engine/apps/api/migrations/0001_initial.py +++ b/src/hope_dedup_engine/apps/api/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.6 on 2024-05-22 13:24 +# Generated by Django 5.0.6 on 2024-05-24 11:45 import django.db.models.deletion import uuid @@ -21,7 +21,7 @@ class Migration(migrations.Migration): fields=[ ("id", models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)), ("name", models.CharField(max_length=100)), - ("reference_pk", models.IntegerField()), + ("reference_pk", models.CharField(max_length=100)), ( "state", models.IntegerField( @@ -62,9 +62,9 @@ class Migration(migrations.Migration): name="Duplicate", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), - ("first_reference_pk", models.IntegerField()), + ("first_reference_pk", models.CharField(max_length=100)), ("first_filename", models.CharField(max_length=255)), - ("second_reference_pk", models.IntegerField()), + ("second_reference_pk", models.CharField(max_length=100)), ("second_filename", models.CharField(max_length=255)), ("score", models.FloatField()), ( @@ -97,7 +97,7 @@ class Migration(migrations.Migration): name="Image", fields=[ ("id", models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)), - ("reference_pk", models.IntegerField()), + ("reference_pk", models.CharField(max_length=100)), ("filename", models.CharField(max_length=255)), ("created_at", models.DateTimeField(auto_now_add=True)), ( diff --git a/src/hope_dedup_engine/apps/api/models/deduplication.py b/src/hope_dedup_engine/apps/api/models/deduplication.py index 7a54d838..817d6a80 100644 --- a/src/hope_dedup_engine/apps/api/models/deduplication.py +++ b/src/hope_dedup_engine/apps/api/models/deduplication.py @@ -5,6 +5,8 @@ from hope_dedup_engine.apps.security.models import ExternalSystem +REFERENCE_PK_LENGTH = 100 + class DeduplicationSet(models.Model): class State(models.IntegerChoices): @@ -15,7 +17,7 @@ class State(models.IntegerChoices): id = models.UUIDField(primary_key=True, default=uuid4) name = models.CharField(max_length=100) - reference_pk = models.IntegerField() + reference_pk = models.CharField(max_length=REFERENCE_PK_LENGTH) state = models.IntegerField( choices=State.choices, default=State.CLEAN, @@ -36,7 +38,7 @@ class State(models.IntegerChoices): class Image(models.Model): id = models.UUIDField(primary_key=True, default=uuid4) deduplication_set = models.ForeignKey(DeduplicationSet, on_delete=models.CASCADE) - reference_pk = models.IntegerField() + reference_pk = models.CharField(max_length=REFERENCE_PK_LENGTH) filename = models.CharField(max_length=255) created_by = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True, blank=True, related_name="+" @@ -46,8 +48,8 @@ class Image(models.Model): class Duplicate(models.Model): deduplication_set = models.ForeignKey(DeduplicationSet, on_delete=models.CASCADE) - first_reference_pk = models.IntegerField() + first_reference_pk = models.CharField(max_length=REFERENCE_PK_LENGTH) first_filename = models.CharField(max_length=255) - second_reference_pk = models.IntegerField() + second_reference_pk = models.CharField(max_length=REFERENCE_PK_LENGTH) second_filename = models.CharField(max_length=255) score = models.FloatField() diff --git a/tests/api/test_deduplication_set_create.py b/tests/api/test_deduplication_set_create.py index 1dd2d71e..62973d03 100644 --- a/tests/api/test_deduplication_set_create.py +++ b/tests/api/test_deduplication_set_create.py @@ -47,9 +47,7 @@ def test_missing_fields_handling(api_client: APIClient, omit: str | tuple[str, . ( ("name", ""), ("name", None), - ("reference_pk", "foo"), ("reference_pk", None), - ("reference_pk", 3.14), ), ) def test_invalid_values_handling(api_client: APIClient, field: str, value: Any) -> None: diff --git a/tests/extras/testutils/factories/api.py b/tests/extras/testutils/factories/api.py index 8d137d9e..66bef975 100644 --- a/tests/extras/testutils/factories/api.py +++ b/tests/extras/testutils/factories/api.py @@ -13,7 +13,7 @@ class Meta: class DeduplicationSetFactory(DjangoModelFactory): name = fuzzy.FuzzyText() - reference_pk = fuzzy.FuzzyInteger(low=1) + reference_pk = fuzzy.FuzzyText() external_system = SubFactory(ExternalSystemFactory) state = DeduplicationSet.State.CLEAN @@ -24,7 +24,7 @@ class Meta: class ImageFactory(DjangoModelFactory): deduplication_set = SubFactory(DeduplicationSetFactory) filename = fuzzy.FuzzyText() - reference_pk = fuzzy.FuzzyInteger(low=1) + reference_pk = fuzzy.FuzzyText() class Meta: model = Image @@ -33,9 +33,9 @@ class Meta: class DuplicateFactory(DjangoModelFactory): deduplication_set = SubFactory(DeduplicationSetFactory) first_filename = fuzzy.FuzzyText() - first_reference_pk = fuzzy.FuzzyInteger(low=1) + first_reference_pk = fuzzy.FuzzyText() second_filename = fuzzy.FuzzyText() - second_reference_pk = fuzzy.FuzzyInteger(low=1) + second_reference_pk = fuzzy.FuzzyText() score = fuzzy.FuzzyFloat(low=0, high=1) class Meta: