-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Bug fixes for the feedback framework #5467
Conversation
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.
@nithusha21 sorry if I'm being pernickety, just a couple of minor changes. Apart from that, the PR LGTM
@@ -267,29 +274,34 @@ def test_thread_closed_job_running(self): | |||
thread_1.put() | |||
|
|||
# Start job. |
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.
nit: please move this comment below with
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
@@ -303,14 +315,16 @@ def test_thread_closed_reopened_again(self): | |||
thread_1.put() | |||
|
|||
# Start job. |
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
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
@@ -321,14 +335,16 @@ def test_thread_closed_reopened_again(self): | |||
thread.put() | |||
|
|||
# Restart job. |
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
@@ -357,14 +375,16 @@ def test_thread_closed_status_changed(self): | |||
thread_1.put() | |||
|
|||
# Start job. |
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.
nit: ditto for this comment
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
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.
One general comment: for every self.swap(..., True) test you should also have a self.swap(..., False) test. We had too many errors here last release and this is a way to make sure that things work correctly in both cases.
I suggest putting the "False" tests into a corresponding *_old_test.py file so we can just delete the file later. Everything in the main codebase should be swapped to True.
assets/constants.js
Outdated
@@ -474,6 +474,8 @@ var constants = { | |||
|
|||
"USE_NEW_SUGGESTION_FRAMEWORK": false, | |||
|
|||
"ENABLE_GENERALIZED_FEEDBACK_THREADS": false, |
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.
Either have this in constants.js or feconf.py, but not both. It is possible to import values from constants.js in the backend code.
core/controllers/feedback_test.py
Outdated
'subject': self.UNICODE_TEST_STRING, | ||
'text': self.UNICODE_TEST_STRING, | ||
}, csrf_token=self.csrf_token, | ||
expect_errors=True, expected_status_int=401) | ||
|
||
thread_url = '%s/%s' % ( | ||
feconf.FEEDBACK_THREAD_URL_PREFIX, '0.dummy_thread_id') | ||
with self.swap(feconf, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', True): |
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 do you need self.swap here? I don't see anything that's dependent on a function.
Codecov Report
@@ Coverage Diff @@
## develop #5467 +/- ##
==========================================
Coverage ? 46.34%
==========================================
Files ? 500
Lines ? 29217
Branches ? 4435
==========================================
Hits ? 13542
Misses ? 15675
Partials ? 0
Continue to review full report at Codecov.
|
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.
@nithusha21 lgtm!
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.
Not sure why this is LGTM. @nithusha21 did you see my comments?
core/controllers/feedback_test.py
Outdated
'suggestion_html': u'Ֆݓॵক', | ||
}, csrf_token=csrf_token) | ||
self.logout() | ||
with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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.
Better to put all the "False" tests in a feedback_old_test.py file, so it can be deleted after the flag is flipped for good.
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.
Moved the old feedback tests to a different suite, also made a suite to test the new suggestions framework with the old feedback framework.
self.assertEqual(msg.author_id, self.user_id_a) | ||
self.assertTrue(msg.received_via_email) | ||
with self.swap( | ||
constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', True): |
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.
What about the False 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.
added
PTAL @seanlip |
assets/constants.js
Outdated
@@ -474,6 +474,8 @@ var constants = { | |||
|
|||
"USE_NEW_SUGGESTION_FRAMEWORK": false, |
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.
Isn't this supposed to be set to true? We flipped it in the last release, it needs to be flipped in develop (or, better still, removed entirely).
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.
Removed completely
core/domain/exp_services_test.py
Outdated
feedback_services.create_suggestion( | ||
self.EXP_ID2, self.user_id, 3, self.initial_state_name, | ||
'description', 'new text') | ||
with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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.
Anything not in an "old" test file should be True. Otherwise it'll break when we remove the constant.
There should be corresponding "old" test files with the False conditions.
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
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 supposed to only work with the flag set as false.
'num_total_threads': 1, | ||
}) | ||
with self.swap( | ||
constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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.
Same note as above.
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.
Created new "old" test file
@@ -88,7 +88,7 @@ def _run_one_off_job(self): | |||
|
|||
def test_message_count(self): | |||
"""Test if the job returns the correct message count.""" | |||
with self.swap(feconf, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): | |||
with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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.
Same note as above.
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.
One off jobs are all mapped to FeedbackThreadModel (the old one). So all of these tests will work only on the old framework.
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.
So what happens when we switch to the new framework and run any of these one-off jobs?
Also if these are going to be deprecated after the flag change, then they should go in an old_feedback_one_off_jobs_test.py file, just like all the rest.
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.
On running after switching, It will just run on entities of the old model, and the changes will not reflect in the newly created models. The jobs here also include jobs to convert from old models to new models. I think these tests are not applicable after the flip, and need to be deprecated after.
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. The codebase needs notes to that effect and there needs to be a TODO recording the specific deprecation tasks required.
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.
(Sorry, not a TODO -- I meant a GitHub issue.)
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.
Hang on -- I looked at this again. The correct thing to have done here would have been to modify the job so that there's a "new" job and an "old" job. The handler would redirect to the correct one based on the status of the flag.
However, I don't think this job is actively being used, and it hasn't been run in a while. So -- in the interest of time, let's just delete it altogether. We can reimplement it later if needed.
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.
Ok.
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.
Renamed the test file.
@@ -90,8 +91,9 @@ def test_status_of_newly_created_thread_is_open(self): | |||
|
|||
def test_get_exp_id_from_thread_id(self): | |||
thread_id = 'exp1.1234' | |||
self.assertEqual( | |||
feedback_services.get_exp_id_from_thread_id(thread_id), 'exp1') | |||
with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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.
Same note as above. "False" tests go in an "old" file. True tests go in this one. The coverage of both files should be the same.
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
self.EXP_ID2, self.user_id, 3, 'state_name', 'description', '') | ||
suggestion = feedback_services.get_suggestion(self.THREAD_ID6) | ||
|
||
with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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.
See above.
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
Not sure why the last commit didn't trigger a travis build to start.... |
assets/constants.js
Outdated
@@ -470,7 +470,9 @@ var constants = { | |||
"\\u001b", "\\u001c", "\\u001d", "\\u001e", "\\u001f" | |||
], | |||
|
|||
"USE_NEW_SUGGESTION_FRAMEWORK": false, | |||
"ENABLE_GCS_STORAGE_FOR_IMAGES": false, |
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 don't understand, why is this here? It's been removed already in develop.
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.
Looks like I incorrectly merged. Removed!
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.
Approving since this PR is important for the release and we should get this in. It's fine to address remaining comments either in this PR or a separate one.
Thanks @nithusha21!
response = self.mock_testapp.get( | ||
'/mock/%s.thread1' % self.published_exp_id, expect_errors=True) | ||
self.assertEqual(response.status_int, 302) | ||
with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', True): |
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.
Do we need to test the False case, or do these handlers simply not exist 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.
Hmmm. I missed these earlier. They do exist in the false case too. Will add the tests.
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
@@ -3150,130 +3148,6 @@ def test_loading_old_exploration_does_not_break_domain_object_ctor(self): | |||
self.assertEqual(exploration.to_yaml(), self.UPGRADED_EXP_YAML) | |||
|
|||
|
|||
class SuggestionActionUnitTests(test_utils.GenericTestBase): |
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.
Where are the corresponding unit tests for the "True" case? These are important to ensure the whole system still works fine after the flag flip.
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.
These are tests for the old suggestion framework, which is deprecated. And we are basically at a point of no return to that framework (since we removed the flag that allowed us to go back to that framework). This is not intended to work with the flag set as true.
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.
OK -- please add inline comments specifying what exactly this test is testing that is no longer available in the new framework. (Be specific -- don't just say "new framework", "old framework" -- talk about exactly what calls are missing in the new framework that prevent this from being tested there.)
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.
Added a comment
@@ -88,7 +88,7 @@ def _run_one_off_job(self): | |||
|
|||
def test_message_count(self): | |||
"""Test if the job returns the correct message count.""" | |||
with self.swap(feconf, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): | |||
with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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.
So what happens when we switch to the new framework and run any of these one-off jobs?
Also if these are going to be deprecated after the flag change, then they should go in an old_feedback_one_off_jobs_test.py file, just like all the rest.
feedback_services.get_exp_id_from_thread_id(thread_id), 'exp1') | ||
|
||
|
||
class SuggestionQueriesUnitTests(test_utils.GenericTestBase): |
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.
Where are the corresponding tests for the "True" case (to ensure that things still work fine after the flag is flipped?
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.
Same as above (regarding old framework)
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.
See my response above too.
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.
Added a comment
@@ -434,7 +434,7 @@ def test_feedback_thread_subscription(self): | |||
subscription_services, 'subscribe_to_exploration', self._null_fn | |||
): | |||
with self.swap( | |||
feconf, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): | |||
constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): |
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 are these not in an "old_*_test.py" file?
What about the corresponding "new" tests?
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 one off job was mapping over FeedbackThreadModel (the old model). That's why I forced the constant to false. I am not sure, but I feel this job needs work on the new framework too? If so, I'll add tests (and change the job appropriately) for the new framework. But as of now, as the model under consideration was the old one, I had set the flag to false
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 job runs in a cron that is triggered weekly (cron.yaml). If you don't fix this properly for the new framework then that cron job will fail in production.
So this needs the same thorough treatment as the other cases. The URL handler called by the cron should redirect to the old job if the flag hasn't been flipped, and the new job if the flag has been flipped. There should be backend tests for each.
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.
Fixed the job, and also added tests for flag true and false cases.
Hi @nithusha21. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks! |
feconf.py
Outdated
@@ -374,6 +374,14 @@ def get_empty_ratings(): | |||
# Disables all the new structures' pages, till they are completed. | |||
ENABLE_NEW_STRUCTURES = False | |||
|
|||
# Flag to disable sending emails related to reviews for suggestions. To be |
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 really need fewer flags. If you can group these into a single flag, or introduce them only later, that would be helpful. At the moment all the flags for the feedback framework are interfering with each other and you need a matrix of test files.
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.
In fact since you don't use these anywhere I recommend just getting rid of them altogether.
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, ignore please. This is already in develop. Not sure why it's showing up as an addition.
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 one more thing. LGTM otherwise.
Unconditional LGTM. Confirmed with @nithusha21 that extra flags were in develop, and were also very small in scope (unlike the two large previous ones). |
* bug fixes for the feedback framework * review changes * review changes (1) * linting fixes * WIP * split into old test suites * linting fixes, and bug fix * remove imports * review changes * remove constant * add tests for acl decorators * review changes * rename file * linting fix
Explanation
Fixes multiple bugs with the feedback framework, which were introduced because of inconsistencies across PRs. Also, on flipping ENABLE_GENERALISED_FEEDBACK_THREADS flag, some backend test failed, and the UI broke. I have fixed those issues too.
PTAL, Thanks!
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.