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

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

Merged
merged 13 commits into from
Jun 1, 2019

Conversation

lilithxxx
Copy link
Contributor

@lilithxxx lilithxxx commented May 8, 2019

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

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR has an appropriate "CHANGELOG: ..." label (If you are unsure of which label to add, ask the reviewers for guidance).
  • The PR follows the style guide.
  • The PR addresses the points mentioned in the codeowner checks for the files/folders changed. (See the codeowner's wiki page.)
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue.

@codecov-io
Copy link

codecov-io commented May 8, 2019

Codecov Report

Merging #6710 into develop will decrease coverage by 1.13%.
The diff coverage is 100%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
core/tests/gae_suite.py 74.41% <ø> (ø) ⬆️
core/domain/value_generators_domain.py 100% <ø> (+8.1%) ⬆️
core/domain/user_query_jobs_one_off_test.py 100% <100%> (ø) ⬆️
core/domain/skill_jobs_one_off_test.py 100% <100%> (ø) ⬆️
core/domain/visualization_registry.py 100% <100%> (+6.06%) ⬆️
extensions/interactions/base_test.py 99.57% <100%> (ø) ⬆️
core/domain/story_jobs_one_off_test.py 100% <100%> (ø) ⬆️
core/domain/visualization_registry_test.py 100% <100%> (ø) ⬆️
core/domain/value_generators_domain_test.py 100% <100%> (ø) ⬆️
...ensions/value_generators/models/generators_test.py 100% <100%> (ø) ⬆️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82ab4a1...67926dd. Read the comment docs.

Copy link
Contributor

@brianrodri brianrodri left a 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!

core/domain/skill_jobs_one_off_test.py Outdated Show resolved Hide resolved
core/domain/skill_jobs_one_off_test.py Outdated Show resolved Hide resolved
core/domain/story_jobs_one_off_test.py Show resolved Hide resolved
core/domain/value_generators_domain.py Show resolved Hide resolved
@nithusha21
Copy link
Contributor

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?

@lilithxxx lilithxxx changed the title Fix 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 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 May 14, 2019
@lilithxxx
Copy link
Contributor Author

@nithusha21 done!

@lilithxxx
Copy link
Contributor Author

@brianrodri @seanlip PTAL!

@seanlip
Copy link
Member

seanlip commented May 21, 2019

The backend tests are failing.

@lilithxxx
Copy link
Contributor Author

lilithxxx commented May 22, 2019

@seanlip the tests were failing due to:

  1. Incorrect version of selenium used in gae_suite.py (used in adding to sys.path)
  2. An __init__.py file is added to all directories in extensions/ so that the python files present there can be imported. This causes a test to fail which counted the number of files present in the directory(now 5 which was previously 4).

I fixed the tests. PTAL

all_value_generators.append(name)

for value_generator in all_value_generators:
self.assertEqual(
Copy link
Member

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?

Copy link
Contributor Author

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(
Copy link
Member

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.

Copy link
Contributor Author

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(
Copy link
Member

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.

Copy link
Contributor Author

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):
Copy link
Member

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.

Copy link
Contributor Author

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',
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

core/domain/user_query_jobs_one_off_test.py Show resolved Hide resolved
core/domain/visualization_registry.py Show resolved Hide resolved
@@ -712,6 +713,51 @@ def test_controller_class_names(self):
self.assertGreater(num_handlers_checked, 150)


class ValueGeneratorNameTests(test_utils.GenericTestBase):
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

extensions/interactions/base_test.py Show resolved Hide resolved
@@ -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(
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@lilithxxx
Copy link
Contributor Author

@seanlip addressed your comments. PTAL!

@seanlip
Copy link
Member

seanlip commented May 23, 2019

Backend tests are failing.

@lilithxxx
Copy link
Contributor Author

@seanlip the backend tests passed!

core/domain/user_query_jobs_one_off_test.py Show resolved Hide resolved
core/domain/visualization_registry.py Show resolved Hide resolved
@@ -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())
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@lilithxxx
Copy link
Contributor Author

@seanlip PTAL

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

LGTM!

@brianrodri
Copy link
Contributor

brianrodri commented May 26, 2019

Hi @aks681, @apb7, @nithusha21, @kevinlee12, PTAL!

Copy link
Contributor

@kevinlee12 kevinlee12 left a comment

Choose a reason for hiding this comment

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

lgtm!

@kevinlee12 kevinlee12 removed their assignment May 26, 2019
@lilithxxx
Copy link
Contributor Author

@aks681 @apb7 @nithusha21 you need to take a look as a code owner. Thanks!

Copy link
Contributor

@nithusha21 nithusha21 left a 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

@nithusha21 nithusha21 removed their assignment May 29, 2019
@lilithxxx
Copy link
Contributor Author

@aks681 @apb7 PTAL

Copy link
Contributor

@apb7 apb7 left a 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!

@apb7 apb7 removed their assignment Jun 1, 2019
Copy link
Contributor

@aks681 aks681 left a comment

Choose a reason for hiding this comment

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

lgtm

@aks681 aks681 merged commit 2046eb0 into oppia:develop Jun 1, 2019
@lilithxxx lilithxxx deleted the backends_test_4 branch June 1, 2019 15:13
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.

8 participants