Skip to content
Open
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
1 change: 0 additions & 1 deletion core/common/checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# Include expanded changelog fields such as names, descriptions, and previous values.
CHANGELOG_ENRICHMENT_VERBOSITY = 4


class ChecksumModel(models.Model):
class Meta:
abstract = True
Expand Down
4 changes: 1 addition & 3 deletions core/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from core.users.models import UserProfile
from core.users.tests.factories import UserProfileFactory
from .backends import OCLOIDCAuthenticationBackend
from .checksums import Checksum
from .checksums import Checksum, ChecksumBase
from .fhir_helpers import translate_fhir_query
from .serializers import IdentifierSerializer
from .validators import URIValidator
Expand Down Expand Up @@ -1340,7 +1340,6 @@ def test_generate(self):

concept1 = ConceptFactory(mnemonic=encode_string('Foo/bar', safe=' '))

from ocldev.checksum import Checksum as ChecksumBase
self.assertEqual(
ChecksumBase('concept', ConceptDetailSerializer(concept1).data, 'standard').generate(),
concept1.checksums['standard']
Expand All @@ -1361,7 +1360,6 @@ def test_generate(self):
mapping1.checksums['smart']
)


class ChecksumViewTest(OCLAPITestCase):
def setUp(self):
self.token = UserProfile.objects.get(username='ocladmin').get_token()
Expand Down
58 changes: 58 additions & 0 deletions core/integration_tests/tests_concepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,64 @@ def test_put_200(self): # pylint: disable=too-many-statements
self.assertEqual(response.data['display_name'], prev_version.display_name)
self.assertEqual(concept.datatype, "N/A")

def test_put_200_when_name_retired_changes_only(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filiperochalopes This test passes on master with ocldev==0.2.3 as well.

names = [
ConceptNameFactory.build(name='Active name', locale='es', locale_preferred=True),
ConceptNameFactory.build(name='Retirable name', locale='es', locale_preferred=False),
]
concept = ConceptFactory(
parent=self.source,
concept_class='Procedure',
datatype='Coded',
names=names,
descriptions=[
ConceptDescriptionFactory.build(
name='Concept description', locale='es', locale_preferred=True
)
]
)
concepts_url = f"/orgs/{self.organization.mnemonic}/sources/{self.source.mnemonic}/concepts/{concept.mnemonic}/"
names_payload = [
{
'external_id': name.external_id,
'name': name.name,
'locale': name.locale,
'locale_preferred': name.locale_preferred,
'name_type': name.type,
'retired': name.name == 'Retirable name',
}
for name in concept.names.order_by('id')
]

response = self.client.put(
concepts_url,
{
'datatype': concept.datatype,
'concept_class': concept.concept_class,
'extras': concept.extras,
'descriptions': [
{
'description': description.name,
'description_type': description.type,
'external_id': description.external_id,
'locale': description.locale,
'locale_preferred': description.locale_preferred,
}
for description in concept.descriptions.order_by('id')
],
'external_id': concept.external_id or '',
'id': concept.mnemonic,
'names': names_payload,
},
HTTP_AUTHORIZATION='Token ' + self.token,
format='json'
)

self.assertEqual(response.status_code, 200)
self.assertEqual(concept.versions.count(), 2)
self.assertFalse(concept.get_latest_version().active_names.get(name='Active name').retired)
self.assertTrue(concept.get_latest_version().retired_names.get(name='Retirable name').retired)

def test_put_200_with_mappings(self): # pylint: disable=too-many-statements
concept = ConceptFactory(parent=self.source, datatype="N/A")
self.assertEqual(concept.versions.count(), 1)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ kombu==5.4.2
django-elasticsearch-dsl==8.0
drf-yasg==1.21.15
git+https://github.com/snyaggarwal/django-queryset-csv
ocldev==0.2.3
ocldev==0.2.4
coverage==7.3.0
tblib==2.0.0
django-ordered-model==3.7.4
Expand Down