alita-sdk 0.3.129__py3-none-any.whl → 0.3.131__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alita_sdk/community/analysis/ado_analyse/__init__.py +100 -0
- alita_sdk/community/analysis/ado_analyse/api_wrapper.py +259 -0
- alita_sdk/community/analysis/github_analyse/__init__.py +94 -0
- alita_sdk/community/analysis/github_analyse/api_wrapper.py +166 -0
- alita_sdk/community/analysis/gitlab_analyse/__init__.py +107 -0
- alita_sdk/community/analysis/gitlab_analyse/api_wrapper.py +173 -0
- alita_sdk/community/analysis/jira_analyse/api_wrapper.py +10 -6
- alita_sdk/langchain/langraph_agent.py +2 -2
- alita_sdk/toolkits/tools.py +24 -5
- alita_sdk/utils/save_dataframe.py +47 -0
- {alita_sdk-0.3.129.dist-info → alita_sdk-0.3.131.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.129.dist-info → alita_sdk-0.3.131.dist-info}/RECORD +19 -9
- tests/test_ado_analysis.py +99 -0
- tests/test_github_analysis.py +87 -0
- tests/test_gitlab_analysis.py +96 -0
- tests/test_jira_analysis.py +33 -37
- {alita_sdk-0.3.129.dist-info → alita_sdk-0.3.131.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.129.dist-info → alita_sdk-0.3.131.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.129.dist-info → alita_sdk-0.3.131.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
import os
|
2
|
+
from unittest.mock import patch
|
3
|
+
import pytest
|
4
|
+
from dotenv import load_dotenv
|
5
|
+
|
6
|
+
from elitea_analyse.github.github_org import GitHubGetOrgLvl
|
7
|
+
from ..alita_sdk.community.analysis.github_analyse.api_wrapper import (
|
8
|
+
GetGithubCommitsFromReposArgs, GetGithubRepositoriesListArgs, GitHubAnalyseWrapper
|
9
|
+
)
|
10
|
+
|
11
|
+
from ..alita_sdk.clients.client import AlitaClient
|
12
|
+
from ..alita_sdk.tools.artifact import ArtifactWrapper
|
13
|
+
from ..alita_sdk.community.utils import check_schema
|
14
|
+
|
15
|
+
|
16
|
+
# Load environment variables from .env file
|
17
|
+
load_dotenv()
|
18
|
+
|
19
|
+
|
20
|
+
@pytest.fixture
|
21
|
+
def github_api_wrapper():
|
22
|
+
base_url = os.getenv("DEPLOYMENT_URL")
|
23
|
+
project_id = os.getenv("PROJECT_ID")
|
24
|
+
api_key = os.getenv("API_KEY")
|
25
|
+
|
26
|
+
if not base_url or not project_id or not api_key:
|
27
|
+
raise ValueError("Environment variables DEPLOYMENT_URL, PROJECT_ID, and API_KEY must be set.")
|
28
|
+
|
29
|
+
client = AlitaClient(
|
30
|
+
base_url=base_url,
|
31
|
+
project_id=int(project_id),
|
32
|
+
auth_token=api_key,
|
33
|
+
)
|
34
|
+
|
35
|
+
artifacts_wrapper = ArtifactWrapper(
|
36
|
+
client=client, bucket=os.getenv("ARTIFACT_BUCKET_PATH", "analyse-gitlab")
|
37
|
+
)
|
38
|
+
check_schema(artifacts_wrapper)
|
39
|
+
|
40
|
+
owner = os.getenv("GITHUB_OWNER")
|
41
|
+
token = os.getenv("GITHUB_TOKEN")
|
42
|
+
if not owner or not token:
|
43
|
+
raise ValueError("GitHub owner and token are required")
|
44
|
+
|
45
|
+
git = GitHubGetOrgLvl(owner, token)
|
46
|
+
|
47
|
+
github_wrapper = GitHubAnalyseWrapper(
|
48
|
+
artifacts_wrapper=artifacts_wrapper,
|
49
|
+
repos=os.getenv("GITHUB_REPOS", ""),
|
50
|
+
git=git
|
51
|
+
)
|
52
|
+
|
53
|
+
check_schema(github_wrapper)
|
54
|
+
|
55
|
+
return github_wrapper
|
56
|
+
|
57
|
+
def test_get_commits_from_repos(github_api_wrapper):
|
58
|
+
args = GetGithubCommitsFromReposArgs(since_after="2025-06-01")
|
59
|
+
result = github_api_wrapper.get_commits_from_repos(since_after=args.since_after)
|
60
|
+
assert isinstance(result, str)
|
61
|
+
assert f"GitHub commits data for {github_api_wrapper.repos} saved" in result
|
62
|
+
|
63
|
+
def test_get_pull_requests_from_repos(github_api_wrapper):
|
64
|
+
args = GetGithubCommitsFromReposArgs(since_after="2025-06-01")
|
65
|
+
result = github_api_wrapper.get_pull_requests_from_repos(since_after=args.since_after)
|
66
|
+
assert isinstance(result, str)
|
67
|
+
assert "GitHub pull requests data saved" in result
|
68
|
+
|
69
|
+
def test_get_repositories_list(github_api_wrapper):
|
70
|
+
with patch(
|
71
|
+
"src.alita_sdk.community.analysis.github_analyse.api_wrapper.dispatch_custom_event",
|
72
|
+
return_value=None,
|
73
|
+
):
|
74
|
+
args = GetGithubRepositoriesListArgs(pushed_after="2025-06-01")
|
75
|
+
result = github_api_wrapper.get_repositories_list(pushed_after=args.pushed_after)
|
76
|
+
assert isinstance(result, str)
|
77
|
+
assert "GitHub repositories list saved" in result
|
78
|
+
|
79
|
+
def test_get_repositories_extended_data(github_api_wrapper):
|
80
|
+
with patch(
|
81
|
+
"src.alita_sdk.community.analysis.github_analyse.api_wrapper.dispatch_custom_event",
|
82
|
+
return_value=None,
|
83
|
+
):
|
84
|
+
args = GetGithubRepositoriesListArgs(pushed_after="2025-06-01")
|
85
|
+
result = github_api_wrapper.get_repositories_extended_data(pushed_after=args.pushed_after)
|
86
|
+
assert isinstance(result, str)
|
87
|
+
assert "Extended repository info that you have access saved" in result
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import os
|
2
|
+
import pytest
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
|
5
|
+
from elitea_analyse.git.git_search import GitLabV4Search
|
6
|
+
|
7
|
+
|
8
|
+
from ..alita_sdk.community.analysis.gitlab_analyse.api_wrapper import (
|
9
|
+
GitLabProjectsListArgs,
|
10
|
+
GitLabCommitsArgs, GitLabAnalyseWrapper
|
11
|
+
)
|
12
|
+
|
13
|
+
from ..alita_sdk.clients.client import AlitaClient
|
14
|
+
from ..alita_sdk.tools.artifact import ArtifactWrapper
|
15
|
+
from ..alita_sdk.community.utils import check_schema
|
16
|
+
|
17
|
+
|
18
|
+
# Load environment variables from .env file
|
19
|
+
load_dotenv()
|
20
|
+
|
21
|
+
|
22
|
+
@pytest.fixture
|
23
|
+
def gitlab_api_wrapper():
|
24
|
+
base_url = os.getenv("DEPLOYMENT_URL")
|
25
|
+
project_id = os.getenv("PROJECT_ID")
|
26
|
+
api_key = os.getenv("API_KEY")
|
27
|
+
|
28
|
+
if not base_url or not project_id or not api_key:
|
29
|
+
raise ValueError("Environment variables DEPLOYMENT_URL, PROJECT_ID, and API_KEY must be set.")
|
30
|
+
|
31
|
+
client = AlitaClient(
|
32
|
+
base_url=base_url,
|
33
|
+
project_id=int(project_id),
|
34
|
+
auth_token=api_key,
|
35
|
+
)
|
36
|
+
|
37
|
+
artifacts_wrapper = ArtifactWrapper(
|
38
|
+
client=client, bucket=os.getenv("ARTIFACT_BUCKET_PATH", "analyse-gitlab")
|
39
|
+
)
|
40
|
+
check_schema(artifacts_wrapper)
|
41
|
+
|
42
|
+
gitlab_url = os.getenv("GITLAB_URL")
|
43
|
+
gitlab_token = os.getenv("GITLAB_TOKEN")
|
44
|
+
|
45
|
+
if not gitlab_url or not gitlab_token:
|
46
|
+
raise ValueError("Environment variables GITLAB_URL and GITLAB_TOKEN must be set.")
|
47
|
+
|
48
|
+
gitlab_search = GitLabV4Search(
|
49
|
+
url=gitlab_url,
|
50
|
+
default_branch_name=os.getenv("GITLAB_DEFAULT_BRANCH", "master"),
|
51
|
+
token=gitlab_token,
|
52
|
+
)
|
53
|
+
|
54
|
+
project_keys = os.getenv("GITLAB_JIRA_PROJECTS", "project1,project2")
|
55
|
+
project_ids = os.getenv("GITLAB_PROJECTS_IDS", "123")
|
56
|
+
|
57
|
+
gitlab_analyse_wrapper = GitLabAnalyseWrapper(
|
58
|
+
artifacts_wrapper=artifacts_wrapper,
|
59
|
+
jira_project_keys=project_keys,
|
60
|
+
project_ids=project_ids,
|
61
|
+
gitlab_search=gitlab_search,
|
62
|
+
)
|
63
|
+
check_schema(gitlab_analyse_wrapper)
|
64
|
+
|
65
|
+
return gitlab_analyse_wrapper
|
66
|
+
|
67
|
+
def test_get_gitlab_projects_list(gitlab_api_wrapper):
|
68
|
+
args = GitLabProjectsListArgs(date="2025-05-01")
|
69
|
+
result = gitlab_api_wrapper.get_gitlab_projects_list(date=args.date)
|
70
|
+
assert isinstance(result, str)
|
71
|
+
assert "You have access to" in result
|
72
|
+
|
73
|
+
def test_get_gitlab_projects_that_in_jira(gitlab_api_wrapper):
|
74
|
+
result = gitlab_api_wrapper.get_gitlab_projects_that_in_jira()
|
75
|
+
assert isinstance(result, str)
|
76
|
+
assert "GitLab projects that match Jira project names." in result
|
77
|
+
|
78
|
+
def test_get_gitlab_commits(gitlab_api_wrapper):
|
79
|
+
project_ids = os.getenv("GITLAB_PROJECTS_IDS")
|
80
|
+
if not project_ids:
|
81
|
+
raise ValueError("Environment variable GITLAB_PROJECTS_IDS must be set.")
|
82
|
+
|
83
|
+
args = GitLabCommitsArgs(project_ids=project_ids, since_date="2010-01-01")
|
84
|
+
result = gitlab_api_wrapper.get_gitlab_commits(
|
85
|
+
project_ids=args.project_ids, since_date=args.since_date
|
86
|
+
)
|
87
|
+
assert isinstance(result, str)
|
88
|
+
assert f"Commits data for project {gitlab_api_wrapper.project_ids} has been saved. " in result
|
89
|
+
|
90
|
+
|
91
|
+
def test_get_gitlab_merge_requests(gitlab_api_wrapper):
|
92
|
+
since_date = "2010-01-01"
|
93
|
+
args = GitLabCommitsArgs(since_date=since_date)
|
94
|
+
result = gitlab_api_wrapper.get_gitlab_merge_requests(project_ids=args.project_ids, since_date=args.since_date)
|
95
|
+
assert isinstance(result, str)
|
96
|
+
assert f"There are no merge requests in the project {gitlab_api_wrapper.project_ids} created after {since_date}"
|
tests/test_jira_analysis.py
CHANGED
@@ -18,13 +18,24 @@ load_dotenv()
|
|
18
18
|
|
19
19
|
|
20
20
|
@pytest.fixture
|
21
|
-
def
|
21
|
+
def jira_api_wrapper():
|
22
|
+
base_url = os.getenv("DEPLOYMENT_URL")
|
23
|
+
project_id = os.getenv("PROJECT_ID")
|
24
|
+
api_key = os.getenv("API_KEY")
|
25
|
+
artifact_bucket_path = os.getenv("ARTIFACT_BUCKET_PATH", "analyse-jira")
|
26
|
+
|
27
|
+
if not base_url or not project_id or not api_key:
|
28
|
+
raise ValueError("Environment variables DEPLOYMENT_URL, PROJECT_ID, and API_KEY must be set.")
|
29
|
+
|
22
30
|
client = AlitaClient(
|
23
|
-
base_url=
|
24
|
-
project_id=int(
|
25
|
-
auth_token=
|
31
|
+
base_url=base_url,
|
32
|
+
project_id=int(project_id),
|
33
|
+
auth_token=api_key,
|
26
34
|
)
|
27
35
|
|
36
|
+
artifacts_wrapper = ArtifactWrapper(client=client, bucket=artifact_bucket_path)
|
37
|
+
check_schema(artifacts_wrapper)
|
38
|
+
|
28
39
|
jira_credentials = {
|
29
40
|
"username": os.getenv("JIRA_USER"),
|
30
41
|
"base_url": os.getenv("JIRA_SERVER"),
|
@@ -33,24 +44,22 @@ def eda_api_wrapper():
|
|
33
44
|
"verify_ssl": False,
|
34
45
|
}
|
35
46
|
jira = connect_to_jira(credentials=jira_credentials)
|
47
|
+
if not jira:
|
48
|
+
raise ValueError("Failed to connect to Jira. Please check your credentials.")
|
36
49
|
|
37
|
-
|
38
|
-
client=client, bucket=os.getenv("ARTIFACT_BUCKET_PATH")
|
39
|
-
)
|
40
|
-
|
41
|
-
check_schema(artifacts_wrapper)
|
42
|
-
eda_wrapper = JiraAnalyseWrapper(
|
50
|
+
jira_wrapper = JiraAnalyseWrapper(
|
43
51
|
artifacts_wrapper=artifacts_wrapper,
|
44
52
|
jira=jira,
|
45
|
-
closed_status=os.getenv("JIRA_CLOSED_STATUS"),
|
46
|
-
defects_name=os.getenv("JIRA_DEFECTS_NAME"),
|
53
|
+
closed_status=os.getenv("JIRA_CLOSED_STATUS", "Done"),
|
54
|
+
defects_name=os.getenv("JIRA_DEFECTS_NAME", "Defect"),
|
47
55
|
custom_fields={"team": "", "defects_environment": ""},
|
56
|
+
project_keys=os.getenv("JIRA_PROJECT", "CARRIER"),
|
48
57
|
)
|
49
|
-
check_schema(
|
50
|
-
return
|
58
|
+
check_schema(jira_wrapper)
|
59
|
+
return jira_wrapper
|
51
60
|
|
52
61
|
|
53
|
-
def test_get_number_of_all_issues(
|
62
|
+
def test_get_number_of_all_issues(jira_api_wrapper):
|
54
63
|
with patch(
|
55
64
|
"src.alita_sdk.community.analysis.jira_analyse.api_wrapper.dispatch_custom_event",
|
56
65
|
return_value=None,
|
@@ -58,27 +67,14 @@ def test_get_number_of_all_issues(eda_api_wrapper):
|
|
58
67
|
args = GetJiraFieldsArgs(
|
59
68
|
project_keys=os.getenv("JIRA_PROJECT"), after_date="2025-01-01"
|
60
69
|
)
|
61
|
-
result =
|
70
|
+
result = jira_api_wrapper.get_number_off_all_issues(
|
62
71
|
args.project_keys, args.after_date
|
63
72
|
)
|
64
73
|
assert "projects" in result
|
65
74
|
assert "projects_summary" in result
|
66
75
|
|
67
76
|
|
68
|
-
def
|
69
|
-
with patch(
|
70
|
-
"src.alita_sdk.community.analysis.jira_analyse.api_wrapper.dispatch_custom_event",
|
71
|
-
return_value=None,
|
72
|
-
):
|
73
|
-
args = GetJiraFieldsArgs(
|
74
|
-
project_keys=os.getenv("JIRA_PROJECT"), after_date="2025-01-01"
|
75
|
-
)
|
76
|
-
result = eda_api_wrapper.get_all_jira_fields(args.project_keys, args.after_date)
|
77
|
-
assert "overall_stat" in result
|
78
|
-
assert "issue_types_stat" in result
|
79
|
-
|
80
|
-
|
81
|
-
def test_get_jira_issues(eda_api_wrapper):
|
77
|
+
def test_get_jira_issues(jira_api_wrapper):
|
82
78
|
with patch(
|
83
79
|
"src.alita_sdk.community.analysis.jira_analyse.api_wrapper.dispatch_custom_event",
|
84
80
|
return_value=None,
|
@@ -91,12 +87,12 @@ def test_get_jira_issues(eda_api_wrapper):
|
|
91
87
|
created_after="2025-01-01",
|
92
88
|
add_filter="",
|
93
89
|
)
|
94
|
-
result =
|
95
|
-
args.
|
96
|
-
args.
|
97
|
-
args.
|
98
|
-
args.
|
99
|
-
args.
|
100
|
-
args.add_filter,
|
90
|
+
result = jira_api_wrapper.get_jira_issues(
|
91
|
+
closed_issues_based_on=args.closed_issues_based_on,
|
92
|
+
resolved_after=args.resolved_after,
|
93
|
+
updated_after=args.updated_after,
|
94
|
+
created_after=args.created_after,
|
95
|
+
project_keys=args.project_keys,
|
96
|
+
add_filter=args.add_filter,
|
101
97
|
)
|
102
98
|
assert "Data has been extracted successfully." in result
|
File without changes
|
File without changes
|
File without changes
|