|
3 | 3 |
|
4 | 4 | import pytest
|
5 | 5 |
|
6 |
| -from sde_collections.models.collection_choice_fields import DocumentTypes |
| 6 | +from sde_collections.models.collection_choice_fields import Divisions, DocumentTypes |
7 | 7 | from sde_collections.models.delta_patterns import (
|
8 | 8 | DeltaDocumentTypePattern,
|
9 | 9 | DeltaExcludePattern,
|
|
16 | 16 | DumpUrlFactory,
|
17 | 17 | )
|
18 | 18 |
|
19 |
| -DELTA_COMPARISON_FIELDS = ["scraped_title"] # Assuming a central definition |
| 19 | +DELTA_COMPARISON_FIELDS = ["scraped_title", "tdamm_tag", "division"] # Assuming a central definition |
20 | 20 |
|
21 | 21 |
|
22 | 22 | @pytest.mark.django_db
|
@@ -80,9 +80,36 @@ def test_url_in_curated_only(self):
|
80 | 80 | assert delta.scraped_title == curated_url.scraped_title
|
81 | 81 |
|
82 | 82 | def test_identical_url_in_both(self):
|
| 83 | + """When DumpUrl and CuratedUrl have identical values, no DeltaUrl should be created.""" |
83 | 84 | collection = CollectionFactory()
|
84 |
| - dump_url = DumpUrlFactory(collection=collection, scraped_title="Same Title") |
85 |
| - CuratedUrlFactory(collection=collection, url=dump_url.url, scraped_title="Same Title") |
| 85 | + |
| 86 | + # Create DumpUrl with specific values |
| 87 | + dump_url = DumpUrlFactory(collection=collection, scraped_title="Same Title", division=Divisions.ASTROPHYSICS) |
| 88 | + |
| 89 | + # Ensure tdamm_tag is explicitly set to match |
| 90 | + dump_url.tdamm_tag_manual = [] |
| 91 | + dump_url.tdamm_tag_ml = [] |
| 92 | + dump_url.save() |
| 93 | + |
| 94 | + # Create CuratedUrl with identical values |
| 95 | + curated_url = CuratedUrlFactory( |
| 96 | + collection=collection, |
| 97 | + url=dump_url.url, # Use the same URL |
| 98 | + scraped_title="Same Title", |
| 99 | + division=Divisions.ASTROPHYSICS, |
| 100 | + ) |
| 101 | + |
| 102 | + # Set identical tdamm_tag values |
| 103 | + curated_url.tdamm_tag_manual = [] |
| 104 | + curated_url.tdamm_tag_ml = [] |
| 105 | + curated_url.save() |
| 106 | + |
| 107 | + # Verify fields are identical before migration |
| 108 | + assert dump_url.scraped_title == curated_url.scraped_title |
| 109 | + assert dump_url.division == curated_url.division |
| 110 | + assert dump_url.tdamm_tag == curated_url.tdamm_tag |
| 111 | + |
| 112 | + # Migrate and assert |
86 | 113 | collection.migrate_dump_to_delta()
|
87 | 114 | assert not DeltaUrl.objects.filter(url=dump_url.url).exists()
|
88 | 115 |
|
|
0 commit comments