-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1025 - Add test_dispatch_to_batch #1042
Open
avrohomgottlieb
wants to merge
13
commits into
dev
Choose a base branch
from
avrohom/1025-add-test-dispatch-to-batch
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+195
−15
Open
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c749d53
add library instantiation to project factory, add post_generation fun…
avrohomgottlieb e682504
add test_dispatch_to_batch module, add test for project without compu…
avrohomgottlieb 07a450b
add project_id test for dispatch_to_batch
avrohomgottlieb eacb94c
add test_all_projects_have_computed_files tests, add sample testing s…
avrohomgottlieb db9b868
add regenerate-all flag
avrohomgottlieb 3060b49
add job counts log
avrohomgottlieb 6d14543
update project factory to be able to take more relevant args
avrohomgottlieb b55d514
update test methods to account for addition of --regenate-all flag
avrohomgottlieb e9e762d
add docstring to many to many association method in ProjectFactory
avrohomgottlieb 58738c4
assert computed files exist, convert next test to set test
avrohomgottlieb fc847c4
fix queryset immutability bug
avrohomgottlieb 4a6c280
add multiple projects per test to safeguard about queryset immutabili…
avrohomgottlieb 0d2cc42
update help test for dispatch_to_batch command
avrohomgottlieb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
api/scpca_portal/test/management/commands/test_dispatch_to_batch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||
from functools import partial | ||||||
from unittest.mock import patch | ||||||
|
||||||
from django.core.management import call_command | ||||||
from django.test import TestCase | ||||||
|
||||||
from scpca_portal.test.factories import ProjectFactory | ||||||
|
||||||
|
||||||
class TestLoadData(TestCase): | ||||||
def setUp(self): | ||||||
self.dispatch_to_batch = partial(call_command, "dispatch_to_batch") | ||||||
|
||||||
@patch("scpca_portal.management.commands.dispatch_to_batch.Command.submit_job") | ||||||
def test_only_projects_without_computed_files_submitted(self, mock_submit_job): | ||||||
project_with_files = ProjectFactory() | ||||||
|
||||||
project_no_files = ProjectFactory() | ||||||
project_no_files.computed_files.delete() | ||||||
|
||||||
# TODO: remove this patch when we get rid of sample computed file generation | ||||||
with patch("scpca_portal.models.Project.samples_to_generate", []): | ||||||
self.dispatch_to_batch() | ||||||
mock_submit_job.assert_called() | ||||||
|
||||||
submitted_project_ids = set( | ||||||
call.kwargs["project_id"] for call in mock_submit_job.call_args_list | ||||||
) | ||||||
self.assertIn(project_no_files.scpca_id, submitted_project_ids) | ||||||
self.assertNotIn(project_with_files.scpca_id, submitted_project_ids) | ||||||
|
||||||
@patch("scpca_portal.management.commands.dispatch_to_batch.Command.submit_job") | ||||||
def test_project_id_submission(self, mock_submit_job): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
project = ProjectFactory() | ||||||
|
||||||
# TODO: remove this patch when we get rid of sample computed file generation | ||||||
with patch("scpca_portal.models.Project.samples_to_generate", []): | ||||||
self.dispatch_to_batch(project_id=project.scpca_id) | ||||||
mock_submit_job.assert_called() | ||||||
|
||||||
submitted_project_id = mock_submit_job.call_args.kwargs["project_id"] | ||||||
self.assertEqual(project.scpca_id, submitted_project_id) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add a doc string that explains the many to many consideration here