Domain object changes for topic, skill, question models#6989
Domain object changes for topic, skill, question models#6989seanlip merged 23 commits intooppia:developfrom
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
| filename, 490, 120) | ||
|
|
||
|
|
||
| def mock_validate_rte_format(unused_html_list, unused_rte_format): |
There was a problem hiding this comment.
Any reason we use mocks rather than actually fixing the yaml?
There was a problem hiding this comment.
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.
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.)"
core/domain/exp_jobs_one_off_test.py
Outdated
| 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.
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.
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.
I see, OK. But you need to add comments about this to explain, it's not obvious. Do so above line 1793 and elsewhere.
|
@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
| # 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.
Can you change the name to mock_validate_rte_format_for_v26?
core/domain/exp_domain_test.py
Outdated
| # 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.
Can you change the name to mock_validate_customization_args_for_v27?
| 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.
Spelling: commit not commtit
entity --> the entity
|
|
||
| suggestion.change.question_dict[ | ||
| 'question_state_data_schema_version'] = 0 | ||
| question_dict = suggestion.change.question_dict |
There was a problem hiding this comment.
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!
seanlip
left a comment
There was a problem hiding this comment.
Basically LGTM, just a few more small things. Thanks @ankita240796!
| 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.
Just to check, why are we deleting this and the following test functions?
There was a problem hiding this comment.
This is already being tested in skill_domain_test.SkillChangeTests
| skill.skill_contents.worked_examples[0].to_dict(), | ||
| new_worked_examples) | ||
|
|
||
| def test_cannot_update_skill_contents_property_with_invalid_change_dict( |
|
@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! |
bansalnitish
left a comment
There was a problem hiding this comment.
LGTM, Thanks @ankita240796!
| """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.
/cc @import-keshav this change should fix the issue you mentioned about src validation 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_domainandquestion_domainby 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.pyandbash scripts/run_frontend_tests.sh.