-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Domain object changes for topic, skill, question models #6989
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #6989 +/- ##
===========================================
+ Coverage 96.35% 96.41% +0.06%
===========================================
Files 374 374
Lines 56070 56381 +311
===========================================
+ Hits 54024 54361 +337
+ Misses 2046 2020 -26
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #6989 +/- ##
===========================================
+ Coverage 96.71% 96.75% +0.03%
===========================================
Files 374 374
Lines 57074 57458 +384
===========================================
+ Hits 55201 55591 +390
+ Misses 1873 1867 -6
Continue to review full report at Codecov.
|
core/domain/exp_domain_test.py
Outdated
@@ -37,6 +37,14 @@ def mock_get_filename_with_dimensions(filename, unused_exp_id): | |||
filename, 490, 120) | |||
|
|||
|
|||
def mock_validate_rte_format(unused_html_list, unused_rte_format): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we use mocks rather than actually fixing the yaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will not be able to test the loading from v26 which is text angular since it will not pass the validation for ckeditor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. But then I think you should add a comment or something stating that, it's not obvious. You can do that within these methods, something like "# This mock should only be used for validating textangular content. (The current validation assumes CKEditor formatting, so that content would not pass the current validation.)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
core/domain/exp_jobs_one_off_test.py
Outdated
@@ -41,6 +43,18 @@ | |||
taskqueue_services = models.Registry.import_taskqueue_services() | |||
|
|||
|
|||
def mock_validate_rte_format(unused_html_list, unused_rte_format): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto -- mocking validate() is a bit weird. It suggests that the validation is too strict? Or do we just need to fix our test data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are validating invalid HTML/customization args. The jobs are written to find these invalid HTML/customizations args. If we don't use mocks, the validation will fail during creation and saving of an exploration and the jobs cannot be tested in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, OK. But you need to add comments about this to explain, it's not obvious. Do so above line 1793 and elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@ankita240796, are we expecting multiple assignees to review this PR at the same time? I think one should be the primary reviewer (maybe the mentor) and they should take care of the overall structure of the PR and once they approve you can assign other code-owners to review the PR for the codeowned files. Will it be fine? |
Hi @seanlip, I have addressed the two comments by doing further investigation. PTAL, Thanks! |
core/domain/exp_domain_test.py
Outdated
# This function should be only be used while loading v26 textangular | ||
# exploration. If we do not use a mock there, the loading will | ||
# not pass the validation, since the current html validation | ||
# assumes CKEditor formatting. | ||
def mock_validate_rte_format(unused_html_list, unused_rte_format): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the name to mock_validate_rte_format_for_v26?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
core/domain/exp_domain_test.py
Outdated
# This function should be only be used while loading v27 exploration | ||
# without image caption. If we do not use a mock there, the loading will | ||
# not pass the validation, since the current html validation | ||
# requires image tags to have a caption attribute. | ||
def mock_validate_customization_args(unused_html_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the name to mock_validate_customization_args_for_v27?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -425,6 +438,16 @@ def _validate_commit_cmds_schema(cls, item): | |||
item: ndb.Model. Entity to validate. | |||
""" | |||
change_domain_object = cls._get_change_domain_class(item) | |||
if change_domain_object is None: | |||
# This is for cases where id of entity is invalid | |||
# and no commtit command domain object is found for entity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling: commit not commtit
entity --> the entity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -759,8 +759,9 @@ def test_validate_change_question_state_data_schema_version(self): | |||
|
|||
suggestion.validate() | |||
|
|||
suggestion.change.question_dict[ | |||
'question_state_data_schema_version'] = 0 | |||
question_dict = suggestion.change.question_dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it, but put a comment in the code that links to this (excellent) analysis, and file an issue to investigate further and figure out what the fix is. It might be worth filing an issue on the pylint repo as well, since it's possible that this is an error on their end. Thank you for following up on this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM, just a few more small things. Thanks @ankita240796!
@@ -359,36 +368,6 @@ def test_misconception_id_range(self): | |||
self._assert_validation_error( | |||
'The misconception with id 5 is out of bounds') | |||
|
|||
def test_cannot_create_skill_change_class_with_invalid_change_list(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to check, why are we deleting this and the following test functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already being tested in skill_domain_test.SkillChangeTests
@@ -555,14 +548,6 @@ def test_update_skill_worked_examples(self): | |||
skill.skill_contents.worked_examples[0].to_dict(), | |||
new_worked_examples) | |||
|
|||
def test_cannot_update_skill_contents_property_with_invalid_change_dict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
@AllanYangZhou @nithusha21 @DubeySandeep @aks681 @bansalnitish @apb7 If you could, PTAL and do codeowner reviews on this PR ASAP, since it is blocking three others. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks @ankita240796!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as a codeowner!
@@ -106,7 +106,7 @@ class Image(BaseRteComponent): | |||
def validate(cls, value_dict): | |||
"""Validates Image component.""" | |||
super(Image, cls).validate(value_dict) | |||
filename_re = r'^[A-Za-z0-9+/]*\.((png)|(jpeg)|(gif)|(jpg))$' | |||
filename_re = r'^[A-Za-z0-9+/_-]*\.((png)|(jpeg)|(gif)|(jpg))$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @import-keshav this change should fix the issue you mentioned about src validation right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah right.
This is blocking some other PRs and has been reviewed quite thoroughly, so I am going to go ahead and merge this. |
Explanation
This PR introduces changes to
topic_domain
,skill_domain
andquestion_domain
by updating change domain objects according tochange_domain.BaseChange
. It also adds html validation in subtitled html fields and updates test according to the validation. PRs for topic, skill and question models will be stacked on this PR.Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.