Skip to content

Commit 98979a8

Browse files
authored
Merge pull request #1 from nassauwinter/server_wrappers
Server wrappers: Zephyr Scale Server API wrappers
2 parents 1579dd3 + f9b4fad commit 98979a8

File tree

23 files changed

+767
-74
lines changed

23 files changed

+767
-74
lines changed

.github/workflows/build_and_load_to_pypi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
Build_release:
88

9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-20.04
1010

1111
steps:
1212
- uses: actions/setup-python@v4
@@ -26,7 +26,7 @@ jobs:
2626
2727
- name: Install python dependencies
2828
run: |
29-
cd ${{ github.workspace }}/zephyr-python-api && ls
29+
cd ${{ github.workspace }} && ls
3030
pipenv install --dev
3131
pipenv run pip list --local
3232

.github/workflows/pr_checks.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: PR checks
2+
on:
3+
pull_request:
4+
branches: [ main, dev ]
5+
push:
6+
branches: [ dev ]
7+
8+
jobs:
9+
Run_PR_checks:
10+
11+
runs-on: ubuntu-20.04
12+
strategy:
13+
matrix:
14+
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10' ]
15+
16+
steps:
17+
- name: Check out repository code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Update pip and install pipenv
26+
run: |
27+
pip install --upgrade pip
28+
pip install pipenv
29+
python --version
30+
pip --version
31+
pipenv --version
32+
33+
- name: Install Python dependencies
34+
run: |
35+
cd ${{ github.workspace }} && ls
36+
pipenv install --dev --skip-lock
37+
pipenv run pip list --local
38+
39+
- name: Test with tox
40+
run: pipenv run tox

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2022 Petr Sharapenko
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Pipfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ pytest-mock = "*"
1313
pylint = "*"
1414
build = "*"
1515
twine = "*"
16-
17-
[requires]
18-
python_version = "3.8"
16+
tox-gh-actions = "*"

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
![PyPI](https://img.shields.io/pypi/v/zephyr-python-api)
66
![PyPI - License](https://img.shields.io/pypi/l/zephyr-python-api)
77
### Project description
8-
This is a set of wrappers for Zephyr Scale (TM4J) REST API. This means you can interact with Zephyr Scale without GUI, access it with python code and create automation scripts for your every day interactions.
9-
10-
NOTE: Currently only Scale Cloud wrappers are implemented.
8+
This is a set of wrappers for Zephyr Scale (TM4J) REST API. This means you can interact with Zephyr Scale without GUI, access it with python code and create automation scripts for your every day interactions.
119

1210
To be done:
13-
* Scale Server wrappers implementations
14-
* Usage examples
11+
* More usage examples
12+
* Tests, tests and tests for gods of testing
13+
* Convenient docs
14+
* Implementing higher level wrappers representing Test Case, Test Cycle, etc.
1515

1616
### Installation
1717

@@ -30,7 +30,7 @@ zscale = ZephyrScale(token=<your_token>)
3030

3131
Zephyr Server (TM4J) auth:
3232
```python
33-
from zephyr import API_V1, ZephyrScale
33+
from zephyr import ZephyrScale
3434

3535
# Auth can be made with Jira token
3636
auth = {"token": "<your_jira_token>"}
@@ -41,7 +41,7 @@ auth = {"username": "<your_login>", "password": "<your_password>"}
4141
# or even session cookie dict
4242
auth = {"cookies": "<session_cookie_dict>"}
4343

44-
zscale = ZephyrScale(api=API_V1, base_url=<your_base_url>, **auth)
44+
zscale = ZephyrScale.server_api(base_url=<your_base_url>, **auth)
4545
```
4646

4747
Then it is possible to interact with api wrappers:

examples/server.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""
2+
Usage examples of Zephyr Scale Server API wrappers.
3+
"""
4+
import logging
5+
6+
from zephyr import ZephyrScale
7+
8+
9+
# Enable logging with level Debug for more verbosity
10+
logging.basicConfig(level=logging.DEBUG)
11+
12+
13+
# Specify your Jira context to operate with:
14+
base_url = "https://http://localhost:2990/jira/rest/atm/1.0/"
15+
16+
17+
# Deside the type of authorization. It could be a token, username/password or cookies
18+
auth = {"token": "<your_jira_token>"}
19+
# auth = {"username": "<your_username>", "password": "your_pass"}
20+
# auth = {"cookies": "<your_cookie_dict>"}
21+
22+
# Create an instance of Zephyr Scale
23+
zscale = ZephyrScale.server_api(base_url=base_url, **auth)
24+
25+
26+
# Now we can start playing with the Zephyr API!
27+
test_cases = zscale.api.test_cases
28+
29+
# Get a test case:
30+
case_data = test_cases.get_test_case("<your_case_id>")
31+
32+
# Create a test case:
33+
creation_data = test_cases.create_test_case("<your_project_key>", "Test case name")
34+
35+
# Update a test case:
36+
test_script = {
37+
"type": "STEP_BY_STEP",
38+
"steps": [
39+
{
40+
"description": "Description for the step 1",
41+
"testData": "Some test data",
42+
"expectedResult": "Expectations"
43+
},
44+
{
45+
"description": "Step 2 description",
46+
"testData": "Some more test data",
47+
"expectedResult": "Expected result for the step 2"
48+
}]}
49+
update_data = test_cases.update_test_case("<your_case_id>",
50+
objective=f"New_test_objective",
51+
testScript=test_script)
52+
53+
# Delete a test case:
54+
deleted = test_cases.delete_test_case("<case_id_you_don't_need_anymore>")
55+
56+
# Get test case attachments:
57+
attachments = test_cases.get_attachments("<your_case_id>")
58+
59+
# Create a test case attachment (upload):
60+
upload_result = test_cases.create_attachment("<your_case_id>", "path_to_attachment_file")
61+
62+
# Get the latest execution result for the test case:
63+
execution_data = test_cases.get_latest_result("<your_case_id>")
64+
65+
# Get attachments for a specified step:
66+
test_cases.get_step_attachments("<your_case_id>", "<step_id>")
67+
68+
# Create an attachment for step:
69+
test_cases.create_step_attachment("<your_case_id>", "<step_id>", "path_to_attachment_file")
70+
71+
# Search test cases with JQL:
72+
search = test_cases.search_cases(query='projectKey = "<your_awesome_porojects_key>"')

setup.cfg

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = zephyr-python-api
3-
version = 0.0.1.dev2
3+
version = 0.0.1
44
author = Petr Sharapenko
55
author_email = nassauwinter@gmail.com
66
description = Zephyr (TM4J) Python REST API wrapper
@@ -10,14 +10,17 @@ url = https://github.com/nassauwinter/zephyr-python-api
1010
project_urls =
1111
Bug Tracker = https://github.com/nassauwinter/zephyr-python-api/issues
1212
classifiers =
13+
Programming Language :: Python :: 3.6
1314
Programming Language :: Python :: 3.7
1415
Programming Language :: Python :: 3.8
16+
Programming Language :: Python :: 3.9
17+
Programming Language :: Python :: 3.10
1518
License :: OSI Approved :: Apache Software License
1619
Operating System :: OS Independent
1720

1821
[options]
1922
packages = find:
20-
python_requires = >=3.7
23+
python_requires = >=3.6
2124
install_requires =
2225
requests
2326

tests/pytest.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[pytest]
2+
markers =
3+
unit: test Zephyr Scale modules
4+
integration: test integration with Server/Cloud
5+
6+
log_cli = True
7+
log_cli_level = DEBUG
8+
log_cli_format = %(asctime)s %(levelname)s %(message)s
9+
log_cli_date_format = %Y-%m-%d %H:%M:%S

tests/test_scale.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

tests/unit/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)