-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metrics Collection: Added GALAXY_API_PATH_PREFIX to API call
Jira AA-1892 No-Issue Signed-off-by: Martin Slemr <[email protected]>
- Loading branch information
1 parent
b10dd99
commit 9d903f2
Showing
2 changed files
with
39 additions
and
2 deletions.
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
31 changes: 31 additions & 0 deletions
31
galaxy_ng/tests/unit/app/management/commands/analytics/automation_analytics/test_data.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,31 @@ | ||
import galaxy_ng.app.metrics_collection.common_data | ||
from django.test import TestCase, override_settings | ||
from unittest.mock import MagicMock, patch | ||
from django.conf import settings | ||
from urllib.parse import urljoin | ||
import os | ||
|
||
|
||
class TestAutomationAnalyticsData(TestCase): | ||
@override_settings(ANSIBLE_API_HOSTNAME='https://example.com') | ||
@override_settings(GALAXY_API_PATH_PREFIX='/api-test/xxx') | ||
@patch('galaxy_ng.app.metrics_collection.common_data.requests.request') | ||
def test_api_status_request(self, mock_request): | ||
mock_response = MagicMock(name="mock_response") | ||
mock_response.status_code = 200 | ||
mock_request.return_value = mock_response | ||
|
||
json_response = MagicMock(name="json") | ||
mock_response.json = json_response | ||
|
||
path = os.path.join(settings.GALAXY_API_PATH_PREFIX or '', 'pulp/api/v3/status/') | ||
url = urljoin(settings.ANSIBLE_API_HOSTNAME, path) | ||
assert path == '/api-test/xxx/pulp/api/v3/status/' | ||
assert url == 'https://example.com/api-test/xxx/pulp/api/v3/status/' | ||
|
||
galaxy_ng.app.metrics_collection.common_data.api_status() | ||
|
||
json_response.assert_called_once() | ||
# mock_request.assert_called_with("GET", | ||
# 'https://example.com/api-test/xxx/pulp/api/v3/status/') | ||
json_response.assert_called_once() |