Skip to content

Commit

Permalink
don't generate junit.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
joelee2012 committed Jun 1, 2023
1 parent 218d75a commit 8a0e6f8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
13 changes: 13 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import asyncio
import contextlib
import os
import sys
import time
from pathlib import Path

Expand Down Expand Up @@ -108,3 +110,14 @@ def _retrive(item):
output.append(str(line))
return build, output
return _retrive


# workaround for https://github.com/pytest-dev/pytest-asyncio/issues/371
@pytest.fixture(scope="session")
def event_loop():
policy = asyncio.get_event_loop_policy()
loop = policy.new_event_loop()
yield loop
if loop.is_running():
asyncio.sleep(2)
loop.close()
21 changes: 16 additions & 5 deletions tests/integration/test_01_jenkins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from api4jenkins import Folder
from api4jenkins.job import WorkflowJob
from api4jenkins import Folder, WorkflowJob, AsyncFolder, AsyncWorkflowJob
from api4jenkins.exceptions import BadRequestError, ItemNotFoundError


Expand Down Expand Up @@ -81,16 +80,28 @@ def test_credential(self, jenkins):
assert c.id == 'user-id'


@pytest.mark.asyncio
class TestAsyncJenkins:

async def test_exists(self, async_jenkins):
assert await async_jenkins.exists()

@pytest.mark.parametrize('name,type_', [('not exist', type(None)),
('folder', Folder),
('folder/job', WorkflowJob),
('folder', AsyncFolder),
('folder/job', AsyncWorkflowJob),
('folder/not exist', type(None))])
async def test_get_job(self, async_jenkins, name, type_):
assert isinstance(await async_jenkins.get_job(name), type_)
assert isinstance(await async_jenkins[name], type_)

@pytest.mark.parametrize('name, exception', [('folder', "A job already exists "
"with the name folder"),
('ab@cd', '@ is an unsafe character')],
ids=['exist', 'unsafe'])
async def test_create_job_fail(self, async_jenkins, name, exception):
with pytest.raises(BadRequestError, match=exception):
await async_jenkins.create_job(name, '')

# async def test_copy_job(self, async_jenkins, async_job):
# await async_jenkins.copy_job(async_job.full_name, 'copied_job')
# assert (await async_jenkins['folder/copied_job'])
# await async_jenkins.delete_job('folder/copied_job')
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ commands =
-o junit_family=xunit2 \
--cov-report term \
--cov-report html:tests/unit/htmlcov \
--cov-report xml:tests/unit/cov.xml \
--junit-xml tests/unit/junit.xml
--cov-report xml:tests/unit/coverage.xml

[testenv:pylint]
deps = pylint
Expand All @@ -31,7 +30,7 @@ deps = pytest-cov
passenv = JENKINS_*
commands =
pytest -v --cov=api4jenkins tests/integration \
--asyncio-mode=auto \
--cov-report term \
--cov-report html:tests/integration/htmlcov \
--cov-report xml:tests/integration/cov.xml \
--junit-xml tests/integration/junit.xml
--cov-report xml:tests/integration/coverage.xml

0 comments on commit 8a0e6f8

Please sign in to comment.