-
-
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
Fix part of #6550: Write backend tests for skill_jobs_one_off, story_jobs_one_off, user_query_jobs_one_off , value_generators_domain, and visualization_registry #6710
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #6710 +/- ##
===========================================
- Coverage 95.65% 94.52% -1.14%
===========================================
Files 352 371 +19
Lines 48627 49726 +1099
===========================================
+ Hits 46515 47003 +488
- Misses 2112 2723 +611
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.
Thanks @lilithxxx, I've taken my first pass. PTAL!
That's a fairly large PR title, can we trim it by excluding core/domain/ in front of the files, and dropping the .py at the end? |
@nithusha21 done! |
@brianrodri @seanlip PTAL! |
The backend tests are failing. |
@seanlip the tests were failing due to:
I fixed the tests. PTAL |
core/controllers/base_test.py
Outdated
all_value_generators.append(name) | ||
|
||
for value_generator in all_value_generators: | ||
self.assertEqual( |
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.
Odd, I thought we were expecting to see two value generators.
Instead of checking the count, can we verify the list of class names instead?
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
skill_jobs_one_off.SkillMigrationOneOffJob.enqueue(job_id) | ||
self.process_and_flush_pending_tasks() | ||
|
||
output = skill_jobs_one_off.SkillMigrationOneOffJob.get_output( |
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 think you can pull this and the following statement out of the "with" clause.
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
skill_jobs_one_off.SkillMigrationOneOffJob.create_new()) | ||
skill_jobs_one_off.SkillMigrationOneOffJob.enqueue(job_id) | ||
self.process_and_flush_pending_tasks() | ||
output = skill_jobs_one_off.SkillMigrationOneOffJob.get_output( |
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, minimize what's in "with". Similarly for other 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.
Done
@@ -169,3 +169,45 @@ def test_migration_job_converts_old_skill(self): | |||
expected = [[u'skill_migrated', | |||
[u'1 skills successfully migrated.']]] | |||
self.assertEqual(expected, [ast.literal_eval(x) for x in output]) | |||
|
|||
def test_migration_job_skips_when_new_structure_editor_is_disabled(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.
It took a while to understand why "skips" == "empty output" (which is what this test is actually checking), so at first glance it looked like this test name was misleading. But I think I get it -- we would expect "1 skills successfully migrated" to show up in the success case, and the fact that it doesn't indicates an issue with the job.
It's still worth making this clear, though. Can you add a short comment above the assertEqual below to explain that "If the skill had been successfully migrated, this would include a 'successfully migrated' message. Its absence means that the skill could not be processed."
Ditto for other tests for which this applies.
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 for other tests but not for this once since this test includes new_structure_editor which is now to be removed.
self.process_and_flush_pending_tasks() | ||
output = skill_jobs_one_off.SkillMigrationOneOffJob.get_output( | ||
job_id) | ||
expected = [[u'validation_error', |
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, add explanation of why this implies "skips". Similarly for other 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.
Done
core/controllers/base_test.py
Outdated
@@ -712,6 +713,51 @@ def test_controller_class_names(self): | |||
self.assertGreater(num_handlers_checked, 150) | |||
|
|||
|
|||
class ValueGeneratorNameTests(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.
Let's put this in core/domain/value_generators_domain_test.py
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
@@ -32,8 +32,16 @@ def test_copier(self): | |||
{}, **{'value': '{{a}}', 'parse_with_jinja': False}), '{{a}}') | |||
self.assertEqual(generator.generate_value( | |||
{'a': 'b'}, **{'value': '{{a}}', 'parse_with_jinja': True}), 'b') | |||
self.assertTrue(generator.get_html_template().startswith( |
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.
Here and below, you need to use an expected value that is specific to the value generator under consideration. Otherwise, it's not clear what you are testing -- the snippets you use would appear in pretty much any HTML/JS file.
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
@seanlip addressed your comments. PTAL! |
Backend tests are failing. |
@seanlip the backend tests passed! |
@@ -32,8 +32,15 @@ def test_copier(self): | |||
{}, **{'value': '{{a}}', 'parse_with_jinja': False}), '{{a}}') | |||
self.assertEqual(generator.generate_value( | |||
{'a': 'b'}, **{'value': '{{a}}', 'parse_with_jinja': True}), 'b') | |||
self.assertIn('<object-editor obj-type=', generator.get_html_template()) |
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.
Here and below, you need to use an expected value that is specific to the value generator under consideration. Otherwise, it's not clear what you are testing -- the snippets you use would appear in pretty much any HTML/JS file.
This comment still applies. Use something that's specific to Copier or to RandomSelector, for all four assertions here. Otherwise the test is a bit meaningless -- for example, every JS file starts with a copyright statement.
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
@seanlip PTAL |
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!
Hi @aks681, @apb7, @nithusha21, @kevinlee12, PTAL! |
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!
@aks681 @apb7 @nithusha21 you need to take a look as a code owner. 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 as a codeowner
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 from code owner's perspective. 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
Fixes part of #6550: Write backend tests for core/domain/skill_jobs_one_off_test.py, core/domain/story_jobs_one_off_test.py, core/domain/user_query_jobs_one_off_test.py , core/domain/value_generators_domain_test.py, and core/domain/visualization_registry_test.py
Explanation
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.