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

feat: add endpoint for course transcript details #454

Merged
merged 4 commits into from
Sep 18, 2023

Conversation

BrandonHBodine
Copy link
Member

Context: I'm working on a project that will give edX an automated path for translating transcripts using AI translations services.

This PR is to add an endpoint; that when passed a course_id will retrieve all it's related videos transcripts so that our service will be able to read the transcript files, translate them, and then update the translated transcripts back to VAL.

edxval/api.py Outdated Show resolved Hide resolved
@BrandonHBodine BrandonHBodine force-pushed the edx/bbodine/add-course-transcript-endpoint branch 5 times, most recently from 735661c to 61560a8 Compare September 6, 2023 13:04
@codecov
Copy link

codecov bot commented Sep 6, 2023

Codecov Report

Patch coverage: 96.15% and project coverage change: +0.02% 🎉

Comparison is base (390d8cc) 94.40% compared to head (13aaf4f) 94.42%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
+ Coverage   94.40%   94.42%   +0.02%     
==========================================
  Files          28       28              
  Lines        3001     3051      +50     
  Branches      168      171       +3     
==========================================
+ Hits         2833     2881      +48     
- Misses        150      151       +1     
- Partials       18       19       +1     
Flag Coverage Δ
unittests 94.42% <96.15%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
edxval/urls.py 57.14% <ø> (ø)
edxval/views.py 93.24% <75.00%> (-1.09%) ⬇️
edxval/__init__.py 100.00% <100.00%> (ø)
edxval/api.py 93.73% <100.00%> (+0.19%) ⬆️
edxval/tests/test_api.py 99.82% <100.00%> (+<0.01%) ⬆️
edxval/tests/test_views.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BrandonHBodine BrandonHBodine force-pushed the edx/bbodine/add-course-transcript-endpoint branch from 45b82f0 to 6d55801 Compare September 11, 2023 01:03
@BrandonHBodine BrandonHBodine marked this pull request as ready for review September 11, 2023 01:42
Comment on lines +1118 to +1134
def test_successful_response(self):
"""
Test succesful response from view
"""
with patch(
'edxval.views.get_transcript_details_for_course'
) as mock_transcript_details:
# Simulate a return value when the function is called.
mock_transcript_details.return_value = {}
course_id = 'course-v1:edx+1+2023_05'
url = reverse(self.base_url, args=[course_id])
response = self.client.get(url)

# Verify the function was called once with course_id
mock_transcript_details.assert_called_once_with(course_id)

self.assertEqual(response.status_code, status.HTTP_200_OK)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: You should not mock the internal util here. Instead, setup the required data using factories and verify that view is getting the correct data as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

@BrandonHBodine Hi, this was not addressed. I would suggest creating a followup PR to address this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@DawoudSheraz is this a requirement to getting this released? You included it as a nit; which typically means optional.

The get_transcript_details_for_course is tested with setup data in edxval/tests/test_api.py. Testing it here seems redundant to me.

Please let me know. I have a deadline to demo our feature that uses this in Staging on Thursday.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, not a requirement for release but important from unit testing point of view.
I agree that get_transcript_details_for_course has been tested in edxval/tests/test_api.py but the view is utilizing that util, so we have to ensure that view is working as expected by adding some test data. It is not redundant. Both are testing different parts of the code.

Copy link
Contributor

@DawoudSheraz DawoudSheraz left a comment

Choose a reason for hiding this comment

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

Please ensure that the version is bumped in https://github.com/openedx/edx-val/blob/master/edxval/__init__.py#L5. Once merged, the release will be created from https://github.com/openedx/edx-val/releases which pushes the latest version to PyPi. Once the latest version is available on Pypi, it will be updated in edx-platform.

@BrandonHBodine BrandonHBodine merged commit 0a85bb8 into master Sep 18, 2023
8 checks passed
@BrandonHBodine BrandonHBodine deleted the edx/bbodine/add-course-transcript-endpoint branch September 18, 2023 04:57
@BrandonHBodine
Copy link
Member Author

Please ensure that the version is bumped in https://github.com/openedx/edx-val/blob/master/edxval/__init__.py#L5. Once merged, the release will be created from https://github.com/openedx/edx-val/releases which pushes the latest version to PyPi. Once the latest version is available on Pypi, it will be updated in edx-platform.

@DawoudSheraz Is this a manual process or is it automated somewhere? Do I create a new tag and draft a new release? I walked through that process but noticed that the other releases have assets, zip file and tar, included.

@DawoudSheraz
Copy link
Contributor

Please ensure that the version is bumped in https://github.com/openedx/edx-val/blob/master/edxval/__init__.py#L5. Once merged, the release will be created from https://github.com/openedx/edx-val/releases which pushes the latest version to PyPi. Once the latest version is available on Pypi, it will be updated in edx-platform.

@DawoudSheraz Is this a manual process or is it automated somewhere? Do I create a new tag and draft a new release? I walked through that process but noticed that the other releases have assets, zip file and tar, included.

You would need to draft a new release against master with an appropriate new version. Rest of that is automated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants