Skip to content

Commit

Permalink
Send results using the new endpoint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
pyscht committed Aug 3, 2023
1 parent dd5fbf8 commit bd7ea71
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
25 changes: 24 additions & 1 deletion qase-pytest/example/test_example.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
from qaseio.pytest import qase

import time


@qase.step("Capitalize step")
def capital_case(x):
return x.capitalize()


@qase.id(1)
@qase.title('Test should pass')
@qase.fields(
("severity", "critical"),
("priority", "hight"),
("layer", "unit"),
("description", "Always passes"),
("description", "*Precondition 1*. None."),
)
def test_capital_case():
with qase.step("First step"):
time.sleep(0)
assert capital_case('semaphor') == 'Semaphor'


@qase.id(2)
@qase.title("Test should fail")
@qase.fields(
("severity", "critical"),
("priority", "hight"),
("layer", "unit"),
("description", "Always fails"),
("description", "*Precondition 1*. None."),
)
def test_capital_case2():
assert capital_case('semaphor') == 'semaphor'
with qase.step("Failed step"):
assert capital_case('semaphor') == 'semaphor'
2 changes: 1 addition & 1 deletion qase-pytest/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
attrs==21.4.0
cattrs==1.1.2
pytest~=7.2.2
qase-python-commons>=2.0.0,<2.1.0
qase-python-commons>=2.1.0
filelock==3.10.7
4 changes: 2 additions & 2 deletions qase-pytest/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ long-description = file: README.md
long-description-content-type = text/markdown; charset=UTF-8; variant=GFM
url = https://github.com/qase-tms/qase-python/tree/master/qase-pytest
platforms = any
version = 5.0.1
version = 5.1.0
classifiers =
Development Status :: 5 - Production/Stable
Framework :: Pytest
Expand All @@ -29,7 +29,7 @@ package_dir =
setup_requires = pyscaffold>=3.2a0,<3.3a0
# Add here dependencies of your project (semicolon/line-separated), e.g.
install_requires =
qase-python-commons>=2.0.0,<2.1.0
qase-python-commons>=2.1.0
pytest>=7.2.0
filelock~=3.10.7
more_itertools
Expand Down
33 changes: 32 additions & 1 deletion qase-pytest/src/qaseio/pytest/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from qaseio.pytest.plugin import QasePytestPlugin, QasePytestPluginSingleton

from qaseio.commons import QaseTestOps, QaseReport, ConfigManager
from qaseio.commons import QaseTestOps, QaseTestOpsV2, QaseReport, ConfigManager
from qaseio.pytest.options import QasePytestOptions

import os
Expand Down Expand Up @@ -89,6 +89,37 @@ def pytest_configure(config):
print('⚠️ Switching to local report mode')
reporter = defaultReporter
fallback = None
elif (mode == 'testops-v2'):
if validate_testops_options(config):
if (config.getoption("qase_testops_plan_id", None) is not None):
from qaseio.commons import TestOpsPlanLoader

# Load test plan data from Qase TestOps
loader = TestOpsPlanLoader(
api_token=config.getoption("qase_testops_api_token"),
host=config.getoption("qase_testops_api_host", "qase.io"),
)
execution_plan = loader.load(config.getoption("qase_testops_project"),
int(config.getoption("qase_testops_plan_id")))

reporter = QaseTestOpsV2(
api_token=config.getoption("qase_testops_api_token"),
project_code=config.getoption("qase_testops_project"),
run_id=config.getoption("qase_testops_run_id", None),
plan_id=config.getoption("qase_testops_plan_id", None),
complete_run=config.getoption("qase_testops_run_complete", False),
bulk=config.getoption("qase_testops_bulk", True),
run_title=config.getoption("qase_testops_run_title", None),
host=config.getoption("qase_testops_api_host", "qase.io"),
chunk_size=config.getoption("qase_testops_chunk", 200),
environment=config.getoption("qase_environment", None),
defect=config.getoption("qase_testops_defect", False),
)
fallback = defaultReporter
else:
print('⚠️ Switching to local report mode')
reporter = defaultReporter
fallback = None
else:
reporter = defaultReporter
fallback = None
Expand Down

0 comments on commit bd7ea71

Please sign in to comment.