-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VAN-125800] Added several integration tests.
- Loading branch information
timur_malikov_GITD
committed
Sep 25, 2024
1 parent
d45f08e
commit b792af9
Showing
11 changed files
with
445 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,7 @@ celerybeat.pid | |
|
||
# Environments | ||
.env | ||
.env.d3m | ||
.venv | ||
env/ | ||
venv/ | ||
|
File renamed without changes.
File renamed without changes.
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,33 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
|
||
from visier_api_core import Configuration, ApiClient | ||
|
||
TENANT = 'd3m' | ||
TENANT_CODE = 'WFF_d3m' | ||
|
||
|
||
def create_api(api_class, env_file_path='.env'): | ||
if not os.path.isfile(env_file_path): | ||
raise FileNotFoundError(f"Environment file not found: {env_file_path}") | ||
|
||
load_dotenv(env_file_path) | ||
config = Configuration( | ||
host=os.getenv('VISIER_HOST'), | ||
api_key=os.getenv('VISIER_APIKEY'), | ||
username=os.getenv('VISIER_USERNAME'), | ||
password=os.getenv('VISIER_PASSWORD'), | ||
client_id=os.getenv('VISIER_CLIENT_ID'), | ||
client_secret=os.getenv('VISIER_CLIENT_SECRET'), | ||
redirect_uri=os.getenv('VISIER_REDIRECT_URI'), | ||
vanity=os.getenv('VISIER_VANITY') | ||
) | ||
api_client = ApiClient(config) | ||
return api_class(api_client) | ||
|
||
|
||
def get_query_content(file_name): | ||
file_path = os.path.join('visier_api_data_out/queries', file_name) | ||
with open(file_path, 'r') as file: | ||
return file.read() |
69 changes: 69 additions & 0 deletions
69
integration_tests/visier_api_administration/test_permissions_api.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,69 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
Visier Administration APIs | ||
Visier APIs for managing your tenant or tenants in Visier. You can programmatically manage user accounts in Visier, the profiles and permissions assigned to users, and to make changes in projects and publish projects to production. Administrating tenant users can use administration APIs to manage their analytic tenants and consolidated analytics tenants.<br>**Note:** If you submit API requests for changes that cause a project to publish to production (such as assigning permissions to users or updating permissions), each request is individually published to production, resulting in hundreds or thousands of production versions. We recommend that you use the `ProjectID` request header to make changes in a project, if `ProjectID` is available for the API endpoint. | ||
The version of the OpenAPI document: 22222222.99201.1474 | ||
Contact: [email protected] | ||
Please note that this SDK is currently in beta. | ||
Functionality and behavior may change in future releases. | ||
We encourage you to provide feedback and report any issues encountered during your use. | ||
""" # noqa: E501 | ||
|
||
import unittest | ||
|
||
from integration_tests.utils import TENANT_CODE, create_api | ||
from visier_api_administration.api.permissions_api import PermissionsApi | ||
|
||
|
||
class TestPermissionsApi(unittest.TestCase): | ||
"""PermissionsApi unit test stubs""" | ||
|
||
def setUp(self) -> None: | ||
self.api = create_api(PermissionsApi) | ||
|
||
def tearDown(self) -> None: | ||
pass | ||
|
||
# @unittest.skip("To be implemented") | ||
def test_get_data_security_objects(self) -> None: | ||
"""Test case for get_data_security_objects | ||
Retrieve a list of data security objects | ||
""" | ||
|
||
# Retrieving all security objects | ||
security_objects_dto = self.api.get_data_security_objects(include_details=True, tenant_code=TENANT_CODE) | ||
|
||
self.assertIsNotNone(security_objects_dto) | ||
self.assertIsNotNone(security_objects_dto.analytic_objects) | ||
self.assertGreater(len(security_objects_dto.analytic_objects), 0) | ||
|
||
# Retrieving single security object | ||
analytic_object = security_objects_dto.analytic_objects[0] | ||
security_objects_dto = self.api.get_data_security_objects( | ||
id=[analytic_object.analytic_object_id], | ||
include_details=True, | ||
tenant_code=TENANT_CODE | ||
) | ||
|
||
self.assertIsNotNone(security_objects_dto) | ||
self.assertIsNotNone(security_objects_dto.analytic_objects) | ||
self.assertEqual(len(security_objects_dto.analytic_objects), 1) | ||
self.assertEqual(analytic_object, security_objects_dto.analytic_objects[0]) | ||
|
||
def test_get_permissions(self) -> None: | ||
"""Test case for get_permissions | ||
Retrieve a list of all permissions | ||
""" | ||
permissions_dto = self.api.get_permissions(TENANT_CODE) | ||
self.assertIsNotNone(permissions_dto.permissions) | ||
self.assertGreater(len(permissions_dto.permissions), 0) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
44 changes: 44 additions & 0 deletions
44
integration_tests/visier_api_administration/test_profiles_api.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,44 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
Visier Administration APIs | ||
Visier APIs for managing your tenant or tenants in Visier. You can programmatically manage user accounts in Visier, the profiles and permissions assigned to users, and to make changes in projects and publish projects to production. Administrating tenant users can use administration APIs to manage their analytic tenants and consolidated analytics tenants.<br>**Note:** If you submit API requests for changes that cause a project to publish to production (such as assigning permissions to users or updating permissions), each request is individually published to production, resulting in hundreds or thousands of production versions. We recommend that you use the `ProjectID` request header to make changes in a project, if `ProjectID` is available for the API endpoint. | ||
The version of the OpenAPI document: 22222222.99201.1474 | ||
Contact: [email protected] | ||
Please note that this SDK is currently in beta. | ||
Functionality and behavior may change in future releases. | ||
We encourage you to provide feedback and report any issues encountered during your use. | ||
""" # noqa: E501 | ||
|
||
import unittest | ||
|
||
from integration_tests.utils import create_api | ||
from visier_api_administration.api.profiles_api import ProfilesApi | ||
|
||
|
||
class TestProfilesApi(unittest.TestCase): | ||
"""ProfilesApi unit test stubs""" | ||
|
||
def setUp(self) -> None: | ||
self.api = create_api(ProfilesApi) | ||
|
||
def tearDown(self) -> None: | ||
pass | ||
|
||
def test_get_all_profiles(self) -> None: | ||
"""Test case for get_all_profiles | ||
Retrieve a list of all profiles | ||
""" | ||
|
||
profiles_response_dto = self.api.get_all_profiles() | ||
|
||
self.assertIsNotNone(profiles_response_dto) | ||
self.assertGreater(len(profiles_response_dto.profiles), 0) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
78 changes: 78 additions & 0 deletions
78
integration_tests/visier_api_administration/test_users_v1_api.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,78 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
Visier Administration APIs | ||
Visier APIs for managing your tenant or tenants in Visier. You can programmatically manage user accounts in Visier, the profiles and permissions assigned to users, and to make changes in projects and publish projects to production. Administrating tenant users can use administration APIs to manage their analytic tenants and consolidated analytics tenants.<br>**Note:** If you submit API requests for changes that cause a project to publish to production (such as assigning permissions to users or updating permissions), each request is individually published to production, resulting in hundreds or thousands of production versions. We recommend that you use the `ProjectID` request header to make changes in a project, if `ProjectID` is available for the API endpoint. | ||
The version of the OpenAPI document: 22222222.99201.1474 | ||
Contact: [email protected] | ||
Please note that this SDK is currently in beta. | ||
Functionality and behavior may change in future releases. | ||
We encourage you to provide feedback and report any issues encountered during your use. | ||
""" # noqa: E501 | ||
|
||
import unittest | ||
|
||
from integration_tests.utils import TENANT_CODE, create_api | ||
from visier_api_administration import UserCreationAPIRequestDTO, UserCreationAPIResponseDTO | ||
from visier_api_administration.api.users_v1_api import UsersV1Api | ||
|
||
|
||
class TestUsersV1Api(unittest.TestCase): | ||
"""UsersV1Api unit test stubs""" | ||
|
||
def setUp(self) -> None: | ||
self.api = create_api(UsersV1Api) | ||
|
||
def tearDown(self) -> None: | ||
pass | ||
|
||
def test_add_user(self) -> None: | ||
"""Test case for add_user | ||
Add a user | ||
""" | ||
|
||
# Deleting test user if exists | ||
test_user_email = '[email protected]' | ||
all_users_dto = self.api.get_all_users(tenant_code=TENANT_CODE) | ||
self.assertIsNotNone(all_users_dto) | ||
self.assertGreater(len(all_users_dto.users), 0) | ||
test_user = next((user for user in all_users_dto.users if user.email == test_user_email), None) | ||
if test_user: | ||
api_response = self.api.delete_user_with_http_info(test_user.user_id, tenant_code=TENANT_CODE) | ||
self.assertEqual(api_response.status_code, 204) | ||
|
||
creation_request_dto = UserCreationAPIRequestDTO( | ||
account_enabled='true', | ||
display_name='Creation test User Visier Python SDK', | ||
email=test_user_email, | ||
username=test_user_email | ||
) | ||
|
||
created_api_response = self.api.add_user_with_http_info( | ||
user_creation_api_request_dto=creation_request_dto, | ||
tenant_code=TENANT_CODE | ||
) | ||
self.assertEqual(created_api_response.status_code, 201) | ||
creation_user_dto = UserCreationAPIResponseDTO.from_json(created_api_response.raw_data.decode()) | ||
self.assertIsNotNone(creation_user_dto) | ||
self.assertEqual(creation_request_dto.display_name, creation_user_dto.display_name) | ||
self.assertEqual(creation_request_dto.email, creation_user_dto.email) | ||
self.assertEqual(creation_request_dto.username, creation_user_dto.username) | ||
|
||
def test_get_all_users(self) -> None: | ||
"""Test case for get_all_users | ||
Retrieve a list of all users | ||
""" | ||
users_dto = self.api.get_all_users(tenant_code=TENANT_CODE) | ||
self.assertIsNotNone(users_dto) | ||
self.assertIsNotNone(users_dto.users) | ||
self.assertGreater(len(users_dto.users), 0) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
44 changes: 44 additions & 0 deletions
44
integration_tests/visier_api_data_out/queries/aggregate.json
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,44 @@ | ||
{ | ||
"query": { | ||
"source": { | ||
"metric": "employeeCount" | ||
}, | ||
"axes": [ | ||
{ | ||
"dimensionLevelSelection": { | ||
"dimension": { | ||
"name": "Function", | ||
"qualifyingPath": "Employee" | ||
}, | ||
"levelIds": [ | ||
"Function" | ||
] | ||
} | ||
}, | ||
{ | ||
"dimensionLevelSelection": { | ||
"dimension": { | ||
"name": "Pay_Level", | ||
"qualifyingPath": "Employee" | ||
}, | ||
"levelIds": [ | ||
"Pay_Level" | ||
] | ||
} | ||
} | ||
], | ||
"filters": [ | ||
{ | ||
"selectionConcept": { | ||
"name": "isManager", | ||
"qualifyingPath": "Employee" | ||
} | ||
} | ||
], | ||
"timeIntervals": { | ||
"fromDateTime": "2021-01-01", | ||
"intervalPeriodType": "MONTH", | ||
"intervalCount": 6 | ||
} | ||
} | ||
} |
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,57 @@ | ||
{ | ||
"source": { | ||
"analyticObject": "Applicant" | ||
}, | ||
"columns": [ | ||
{ | ||
"columnName": "ApplicantID", | ||
"columnDefinition": { | ||
"property": { | ||
"name": "Applicant.ApplicantID", | ||
"qualifyingPath": "Applicant" | ||
} | ||
} | ||
}, | ||
{ | ||
"columnName": "Validity_Start", | ||
"columnDefinition": { | ||
"property": { | ||
"name": "Applicant.ValidityStart", | ||
"qualifyingPath": "Applicant" | ||
} | ||
} | ||
}, | ||
{ | ||
"columnName": "Validity_End", | ||
"columnDefinition": { | ||
"property": { | ||
"name": "Applicant.ValidityEnd", | ||
"qualifyingPath": "Applicant" | ||
} | ||
} | ||
}, | ||
{ | ||
"columnName": "Offer_Salary_Amount", | ||
"columnDefinition": { | ||
"property": { | ||
"name": "Applicant.Offer_Salary_Amount", | ||
"qualifyingPath": "Applicant" | ||
} | ||
} | ||
} | ||
], | ||
"sortOptions": [ | ||
{ | ||
"columnIndex": 1, | ||
"sortDirection": "SORT_ASCENDING" | ||
} | ||
], | ||
"timeInterval": { | ||
"fromDateTime": "2021-01-01", | ||
"intervalPeriodType": "MONTH", | ||
"intervalCount": 3 | ||
}, | ||
"options": { | ||
"limit": 10 | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
integration_tests/visier_api_data_out/queries/snapshot.json
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,46 @@ | ||
{ | ||
"source": { | ||
"analyticObject": "Employee_Exit" | ||
}, | ||
"columns": [ | ||
{ | ||
"columnName": "Employee age", | ||
"columnDefinition": { | ||
"property": { | ||
"name": "Employee.Age", | ||
"qualifyingPath": "Employee" | ||
} | ||
} | ||
}, | ||
{ | ||
"columnName": "Employee ID", | ||
"columnDefinition": { | ||
"property": { | ||
"name": "Employee.EmployeeID", | ||
"qualifyingPath": "Employee" | ||
} | ||
} | ||
}, | ||
{ | ||
"columnName": "Effective Date", | ||
"columnDefinition": { | ||
"effectiveDateProperty": {} | ||
} | ||
} | ||
], | ||
"sortOptions": [ | ||
{ | ||
"columnIndex": 2, | ||
"sortDirection": "SORT_DESCENDING" | ||
} | ||
], | ||
"timeIntervals": { | ||
"fromInstant": "1672531200000", | ||
"intervalPeriodType": "MONTH", | ||
"intervalPeriodCount": 1, | ||
"intervalCount": 3 | ||
}, | ||
"options": { | ||
"limit": 10 | ||
} | ||
} |
Oops, something went wrong.