Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PB-286: Remove unique constraint from rel-collection pair #437

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 5.0.7 on 2024-07-30 15:26

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("stac_api", "0043_remove_collection_external_asset_pattern_and_more"),
]

operations = [
migrations.AlterUniqueTogether(
name="collectionlink",
unique_together=set(),
),
]
1 change: 0 additions & 1 deletion app/stac_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ class CollectionLink(Link):
)

class Meta:
unique_together = (('rel', 'collection'),)
ordering = ['pk']
triggers = generate_child_triggers('collection', 'CollectionLink')

Expand Down
21 changes: 21 additions & 0 deletions app/tests/tests_09/sample_data/collection_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
}
}

multiple_links = {
'link-1': {
'rel': 'license',
'href': 'https://www.example1.com/license',
'title': 'This is an extra collection link',
'link_type': 'description'
},
'link-2': {
'rel': 'license',
'href': 'https://www.example2.com/license',
'title': 'This is another extra collection link',
'link_type': 'description'
}
}

links_invalid = {
'link-invalid': {
'title': 'invalid collection link relation',
Expand Down Expand Up @@ -83,6 +98,12 @@
'license': 'proprietary',
'links': [links_invalid['link-invalid']]
},
'collection-multiple-links': {
'name': 'collection-multiple-link',
'description': 'This is a collection with multiple user links',
'license': 'proprietary',
'links': [multiple_links['link-1'], multiple_links['link-2']]
},
'collection-invalid-providers': {
'name': 'collection-invalid-provider',
'description': 'This is a collection with invalid provider',
Expand Down
7 changes: 7 additions & 0 deletions app/tests/tests_09/test_collection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def test_create_collection_invalid_links(self):
name="collection-invalid-links", sample="collection-invalid-links", db_create=True
)

def test_create_collection_multiple_links(self):
# try to create a collection with multiple links of the same type.
# Should not raise any errors.
self.factory.create_collection_sample(
name="collection-multiple-links", sample="collection-multiple-links", db_create=True
)

def test_create_collection_invalid_providers(self):
# try to create a collection with invalid collection name
with self.assertRaises(
Expand Down
21 changes: 21 additions & 0 deletions app/tests/tests_10/sample_data/collection_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
}
}

multiple_links = {
'link-1': {
'rel': 'license',
'href': 'https://www.example1.com/license',
'title': 'This is an extra collection link',
'link_type': 'description'
},
'link-2': {
'rel': 'license',
'href': 'https://www.example2.com/license',
'title': 'This is another extra collection link',
'link_type': 'description'
}
}

links_invalid = {
'link-invalid': {
'title': 'invalid collection link relation',
Expand Down Expand Up @@ -83,6 +98,12 @@
'license': 'proprietary',
'links': [links_invalid['link-invalid']]
},
'collection-multiple-links': {
'name': 'collection-multiple-link',
'description': 'This is a collection with multiple user links',
'license': 'proprietary',
'links': [multiple_links['link-1'], multiple_links['link-2']]
},
'collection-invalid-providers': {
'name': 'collection-invalid-provider',
'description': 'This is a collection with invalid provider',
Expand Down
7 changes: 7 additions & 0 deletions app/tests/tests_10/test_collection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def test_create_collection_invalid_links(self):
name="collection-invalid-links", sample="collection-invalid-links", db_create=True
)

def test_create_collection_multiple_links(self):
# try to create a collection with multiple links of the same type.
# Should not raise any errors.
self.factory.create_collection_sample(
name="collection-multiple-links", sample="collection-multiple-links", db_create=True
)

def test_create_collection_invalid_providers(self):
# try to create a collection with invalid collection name
with self.assertRaises(
Expand Down