Skip to content

Commit

Permalink
feat: updates license serializer to include the customer agreement fr…
Browse files Browse the repository at this point in the history
…om subscription plans (#597)

* feat: updates license serializer to include the customer agreement from subscription plans

* chore: update testing

* chore: PR feedback
  • Loading branch information
brobro10000 authored Feb 21, 2024
1 parent d156536 commit 6dd8caf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions license_manager/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class LicenseSerializer(serializers.ModelSerializer):
"""

subscription_plan_uuid = serializers.UUIDField(source='subscription_plan_id')
customer_agreement = CustomerAgreementSerializer(source='subscription_plan.customer_agreement')

class Meta:
model = License
Expand All @@ -160,6 +161,7 @@ class Meta:
'subscription_plan_uuid',
'revoked_date',
'activation_key',
'customer_agreement'
]


Expand Down
5 changes: 5 additions & 0 deletions license_manager/apps/api/v1/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from rest_framework import status
from rest_framework.test import APIClient

from license_manager.apps.api.serializers import CustomerAgreementSerializer
from license_manager.apps.api.tests.factories import BulkEnrollmentJobFactory
from license_manager.apps.api.utils import (
acquire_subscription_plan_lock,
Expand Down Expand Up @@ -335,6 +336,7 @@ def _assert_license_response_correct(response, subscription_license):
'revoked_date',
'activation_key',
'activation_date',
'customer_agreement'
}
assert set(response.keys()) == expected_fields
assert response['uuid'] == str(subscription_license.uuid)
Expand All @@ -344,6 +346,9 @@ def _assert_license_response_correct(response, subscription_license):
assert response['activation_key'] == str(subscription_license.activation_key)
assert response['activation_date'] == _iso_8601_format(subscription_license.activation_date)
assert response['last_remind_date'] == _iso_8601_format(subscription_license.last_remind_date)
assert response['customer_agreement'] == CustomerAgreementSerializer(
subscription_license.subscription_plan.customer_agreement
).data


@pytest.mark.django_db
Expand Down
1 change: 1 addition & 0 deletions license_manager/apps/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class LearnerLicensesViewSet(
}
]
}
customer_agreement: <CustomerAgreementSerializer>
user_email: "[email protected]"
uuid: "4e03efb7-b4ea-4a52-9cfc-11519920a40a"
]
Expand Down

0 comments on commit 6dd8caf

Please sign in to comment.