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

course export with unpublished transcript fix #255

Merged
merged 1 commit into from
Aug 7, 2020

Conversation

Ali-D-Akbar
Copy link
Contributor

@Ali-D-Akbar Ali-D-Akbar commented Aug 5, 2020

PROD-1128

Description

Exporting a course while having a video transcript that is yet to be published causes the export to fail. Exporting works fine in case of a published transcript file.

Fix:

The lack of directories in the file system causes this issue to occur. There is a static subdirectory that needs to be made before creating the transcript file. So if the directory doesn't exist, it must be made in the File System.

Reviewers

Post Review

  • Squash & Rebase commit

"""
language_code = 'en'
video_id = constants.VIDEO_DICT_FISH['edx_video_id']
transcript_file_name = u'super-soaker-en.srt'
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for u

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing it.

)

delegate_fs = OSFS(self.temp_dir)
file_system = delegate_fs.makedir(constants.EXPORT_IMPORT_COURSE_DIR, recreate=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

why explicit create here?

Copy link
Contributor Author

@Ali-D-Akbar Ali-D-Akbar Aug 6, 2020

Choose a reason for hiding this comment

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

it is a temporary course directory that is always made before exporting the transcript.
EXPORT_IMPORT_COURSE_DIR is an OSFS object having a directory something like /tmp/tmpbo814ql3 and in this directory, create_transcript_file will make a static_dir in case of an unpublished transcript.

(static_dir is course/static in this case)


delegate_fs = OSFS(self.temp_dir)
file_system = delegate_fs.makedir(constants.EXPORT_IMPORT_COURSE_DIR, recreate=True)
# static_dir isn't made when the transcript is not published
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of inline comments, explain the scenario in unit test docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll move it into the docstring.

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.

Nits to address before merging

Comment on lines 2917 to 2918
# Verify transcript file is created.
self.assertIn(transcript_file_name, file_system.listdir(constants.EXPORT_IMPORT_STATIC_DIR))

# Also verify the content of created transcript file.
expected_transcript_content = File(open(expected_transcript_path, 'rb')).read()
Copy link
Contributor

Choose a reason for hiding this comment

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

remove internal comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

internal comments have been removed.

Comment on lines 2893 to 2895
In a course with unpublished transcript, static_dir directory isn't made
so we don't explicitly make static_dir in this test
create_transcript_file will make static_dir inside file_system
Copy link
Contributor

Choose a reason for hiding this comment

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

don't mention exact function names here. Just give context that directory will be created if not present etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added an improved docstring.

@DawoudSheraz
Copy link
Contributor

Please update the version in setup.py before merging.

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.

2 participants