-
Notifications
You must be signed in to change notification settings - Fork 10
AAP-47731: create run_pattern_instance_task for PatternIstanceViewSet #16
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
AAP-47731: create run_pattern_instance_task for PatternIstanceViewSet #16
Conversation
|
57ca03b
to
1e063c4
Compare
6606173
to
122c7d1
Compare
core/services.py
Outdated
Downloads and extracts a collection tarball to a temporary directory. | ||
Args: | ||
collection: The name of the collection (e.g., 'my_namespace.my_collection'). |
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.
collection: The name of the collection (e.g., 'my_namespace.my_collection'). | |
collection: The name of the collection (e.g., 'my_namespace-my_collection'). |
) | ||
mock_update_status.assert_any_call( | ||
task, "Completed", {"info": "Pattern processed successfully"} | ||
) |
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.
test_full_status_update_flow
test already covers everything this test does and more. Should we merge both the tests?
core/tests/test_services.py
Outdated
pattern_name="test_pattern", | ||
) | ||
task = Task.objects.create(status="Initiated", details={}) | ||
temp_dir = tempfile.mkdtemp() |
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.
SharedDataMixin
already has a helper, create_temp_collection_dir, that does this. SHould we use that here?
temp_dir= self.create_temp_collection_dir()
core/tests/test_views.py
Outdated
response = self.client.post(url, data, format="json") | ||
@patch("core.views.run_pattern_instance_task") | ||
def test_create_pattern_instance_and_task(self, mock_run_task): | ||
request = self.factory.post( |
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.
Can we use self.client here to be consistent with the other tests?
f43618a
to
27b74eb
Compare
@GomathiselviS Thank you for reviewing. Can you please a look at #15 since that one will need to be merged first. I have already applied some of your suggestions to #15, so I'll appreciate your review on that PR too. Thanks. |
0fe6b20
to
56040b6
Compare
core/utils/controller/client.py
Outdated
if results: | ||
logger.debug( | ||
f"""Resource already exists. Returning | ||
existing resource: {results[0]}""" | ||
) |
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.
Had to alter line length here to make the linter happy, which led to a slightly more confusing-looking diff
core/utils/controller/helpers.py
Outdated
|
||
role_id = roles_resp["results"][0]["id"] | ||
|
||
for auto in automations: |
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.
The function iterates through each job template and then through each user and team, making a separate POST API call for every single role assignment. Can this be refactored to perform role assignments in bulk?
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 do not see the API supporting bulk operations for role assignment. https://ansible.readthedocs.io/projects/awx/en/latest/rest_api/api_ref.html#/Bulk https://ansible.readthedocs.io/projects/awx/en/24.6.1/userguide/rbac.html
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
612843e
to
f70ac1d
Compare
2640e93
to
5869392
Compare
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.
@alinabuzachis will you squash the commits before you merge this please? Thank you! |
9dc3d52
to
e6505e7
Compare
Signed-off-by: Alina Buzachis <[email protected]>
e6505e7
to
c525965
Compare
Depends On #15
https://issues.redhat.com/browse/AAP-47731