Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1936 | Adding more things to Collection bri…
Browse files Browse the repository at this point in the history
…ef serializer
  • Loading branch information
snyaggarwal committed Oct 4, 2024
1 parent 83dcbb2 commit cd267e7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions core/collections/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@

class CollectionMinimalSerializer(AbstractResourceSerializer):
id = CharField(source='mnemonic')
type = CharField(source='resource_type')

class Meta:
model = Collection
fields = AbstractResourceSerializer.Meta.fields + ('id', 'url')
fields = AbstractResourceSerializer.Meta.fields + ('id', 'url', 'type', 'name', 'description')


class CollectionVersionMinimalSerializer(ModelSerializer):
Expand All @@ -40,7 +41,7 @@ class CollectionVersionMinimalSerializer(ModelSerializer):

class Meta:
model = Collection
fields = ('id', 'version_url', 'type', 'short_code', 'released', 'autoexpand')
fields = ('id', 'version_url', 'type', 'short_code', 'released', 'autoexpand', 'description', 'name')

@staticmethod
def get_autoexpand(obj):
Expand Down
2 changes: 2 additions & 0 deletions core/collections/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ def test_referenced_collections_distribution(self): # pylint: disable=too-many-
'short_code': collection.mnemonic,
'released': False,
'autoexpand': True,
'description': ANY,
'name': ANY,
'distribution': {
'include_reference': True,
'concepts': 0, # no expansion
Expand Down
11 changes: 10 additions & 1 deletion core/integration_tests/tests_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,16 @@ def test_get_200(self):

self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 1)
self.assertEqual(response.data[0], {'id': coll.mnemonic, 'url': coll.uri})
self.assertEqual(
response.data[0],
{
'id': coll.mnemonic,
'url': coll.uri,
'type': 'Collection',
'name': coll.name,
'description': coll.description
}
)

def test_post_201(self):
org = OrganizationFactory(mnemonic='org')
Expand Down

0 comments on commit cd267e7

Please sign in to comment.