Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
add pytest cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shijl0925 committed Aug 4, 2024
1 parent f2bcbc2 commit 5935f27
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 5 deletions.
2 changes: 0 additions & 2 deletions sonarqube/rest/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class SonarQubeIssues(RestClient):
SonarQube issues Operations
"""

MAX_SEARCH_NUM = 100

def get_issue(self, key):
result = self.search_issues(issues=key)
issues = result.get("issues", [])
Expand Down
2 changes: 0 additions & 2 deletions sonarqube/rest/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class SonarQubeUsers(RestClient):
SonarQube users Operations
"""

MAX_SEARCH_NUM = 200

def get_user(self, login):
result = self.search_users(q=login)
users = result.get("users", [])
Expand Down
15 changes: 15 additions & 0 deletions tests/test_ce_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Jialiang Shi
import logging

logger = logging.getLogger(__name__)


def test_search_tasks(sonar_client):
component = "shijl0925_python-gerrit-api"
tasks = sonar_client.ce.search_tasks(
component=component, status="IN_PROGRESS,SUCCESS,FAILED,CANCELED", p=1, ps=10
)

assert len(tasks.get("tasks"))
1 change: 0 additions & 1 deletion tests/test_issue_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ def test_search_issues(sonar_client):
)

assert len(res.get("issues"))

15 changes: 15 additions & 0 deletions tests/test_project_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Jialiang Shi
import logging

logger = logging.getLogger(__name__)


def test_search_projects(sonar_client):
organization = "williamsedmond90"
resp = sonar_client.projects.search_projects(organization=organization)

projects = [item["key"] for item in resp.get("components", [])]

assert len(projects) >= 0
12 changes: 12 additions & 0 deletions tests/test_project_tag_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Jialiang Shi
import logging

logger = logging.getLogger(__name__)


def test_search_project_tags(sonar_client):
res = sonar_client.project_tags.search_project_tags()

assert "tags" in res
15 changes: 15 additions & 0 deletions tests/test_rule_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Jialiang Shi
import logging

logger = logging.getLogger(__name__)


def test_search_rules(sonar_client):
res = sonar_client.rules.search_rules(
organization="shijl0925",
languages="py"
)

assert "rules" in res
11 changes: 11 additions & 0 deletions tests/test_user_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Jialiang Shi
import logging

logger = logging.getLogger(__name__)


def test_search_users(sonar_client):
res = sonar_client.users.search_users()
assert "users" in res
14 changes: 14 additions & 0 deletions tests/test_user_group_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Jialiang Shi
import logging

logger = logging.getLogger(__name__)


def test_search_user_groups(sonar_client):
res = sonar_client.user_groups.search_user_groups(
organization="shijl0925",
)

assert "groups" in res

0 comments on commit 5935f27

Please sign in to comment.