sonarqube happy as well
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3485bf5123
commit
887ed5c0ef
@ -13,7 +13,7 @@ steps:
|
||||
image: python:3-alpine
|
||||
commands:
|
||||
- "pip install -r requirements.txt"
|
||||
- "pytest --cov=app tests/"
|
||||
- "pytest --cov=app --cov-report xml:coverage.xml tests/"
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
env.sh
|
||||
__pycache__
|
||||
.pytest_cache
|
||||
*.xml
|
0
.scannerwork/.sonar_lock
Normal file
0
.scannerwork/.sonar_lock
Normal file
6
.scannerwork/report-task.txt
Normal file
6
.scannerwork/report-task.txt
Normal file
@ -0,0 +1,6 @@
|
||||
projectKey=test
|
||||
serverUrl=http://localhost:9000
|
||||
serverVersion=9.4.0.54424
|
||||
dashboardUrl=http://localhost:9000/dashboard?id=test
|
||||
ceTaskId=AYDouXJ4vMwlS3L7ASHs
|
||||
ceTaskUrl=http://localhost:9000/api/ce/task?id=AYDouXJ4vMwlS3L7ASHs
|
@ -4,15 +4,15 @@ import gitlab
|
||||
import os
|
||||
|
||||
|
||||
def getProject(client, project_name):
|
||||
def get_project(client, project_name):
|
||||
return client.projects.get(project_name)
|
||||
|
||||
|
||||
def getLanguage(project):
|
||||
def get_language(project):
|
||||
return list(project.languages().items())
|
||||
|
||||
|
||||
def helmSet(lang):
|
||||
def helm_set(lang):
|
||||
ret = ''
|
||||
for i in range(len(lang)):
|
||||
ret += f"--set global.language[{i}]={lang[i][0]}"
|
||||
@ -21,4 +21,4 @@ def helmSet(lang):
|
||||
|
||||
if __name__ == '__main__':
|
||||
with gitlab.Gitlab(url=os.environ['GITLAB_URL'], private_token=os.environ['GITLAB_TOKEN'], user_agent='my-package/1.0.0') as gl:
|
||||
print(helmSet(getLanguage(getProject(gl, 'root/test'))), end=" ")
|
||||
print(helm_set(get_language(get_project(gl, 'root/test'))), end=" ")
|
||||
|
5
sonar-project.properties
Normal file
5
sonar-project.properties
Normal file
@ -0,0 +1,5 @@
|
||||
sonar.projectKey=test
|
||||
sonar.sources=app
|
||||
sonar.host.url=http://localhost:9000
|
||||
sonar.python.version=3.10
|
||||
sonar.python.coverage.reportPaths=./coverage.xml
|
@ -1,5 +1,5 @@
|
||||
from unittest.mock import MagicMock, patch
|
||||
from app.languages import getProject, helmSet
|
||||
from app.languages import get_project, helm_set
|
||||
import gitlab
|
||||
from gitlab.v4.objects import ProjectManager as pm
|
||||
|
||||
@ -126,21 +126,21 @@ def test_get_project():
|
||||
'access_level': 50,
|
||||
'notification_level': 3},
|
||||
'group_access': None}}
|
||||
with patch.object(pm, 'get', return_value=project_object) as mock_method:
|
||||
with patch.object(pm, 'get', return_value=project_object):
|
||||
gl = gitlab.Gitlab()
|
||||
project = getProject(gl, 'root/test')
|
||||
project = get_project(gl, 'root/test')
|
||||
assert project['id'] == 34
|
||||
|
||||
|
||||
def test_get_language():
|
||||
getLanguage = MagicMock(return_value=[('Go', 100.0)])
|
||||
get_language = MagicMock(return_value=[('Go', 100.0)])
|
||||
|
||||
expected = [('Go', 100.0)]
|
||||
actual = getLanguage("project")
|
||||
actual = get_language("project")
|
||||
assert expected == actual
|
||||
|
||||
|
||||
def test_helm_set():
|
||||
excepted = '--set global.language[0]=Go'
|
||||
actual = helmSet([('Go', 100.0)])
|
||||
actual = helm_set([('Go', 100.0)])
|
||||
assert excepted == actual
|
||||
|
Loading…
Reference in New Issue
Block a user