-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtestrail-examples.py
79 lines (51 loc) · 2 KB
/
testrail-examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
# one import to rule them all
from testrail import Testrail
# first thing to do is to configure where your testrail connection
Testrail(host='192.168.1.1', port='8080',
user='[email protected]', password='somepassword')
################################################################################
# Basic usage
# Get users list
for user in Testrail.users():
print(user.name)
# Get user by his name
me = Testrail.get_user_by_name('Super QA')
print(me.id, me.email)
# Get all projects
for project in Testrail.projects():
print(project.name)
# Or get only active (not completed) projects
for project in Testrail.projects(is_completed=False):
print(project.name)
# Change project description
my_project = Testrail.get_project_by_name('My Favourite Project')
print(my_project.announcement)
my_project.update(announcement='This announcement was updated!')
print(my_project.announcement)
# Explore project`s milestones, suites, test plans and test runs
my_project = Testrail.get_project_by_name('My Favourite Project')
for milestone in my_project.milestones():
print(milestone.name)
for suite in my_project.suites():
print(suite.name)
for plan in my_project.plans():
print(plan.name)
for run in my_project.runs():
print(run.name)
# Create new test run
my_project = Testrail.get_project_by_name('My Favourite Project')
suite = my_project.get_suite_by_name('Master')
cases_to_run = suite.cases(types=['Functionality', 'UI'],
priorities=['Normal'])
new_run = suite.add_run(name='Normal func test', assignedto='V.Spiridonov',
include_all=False, cases=cases_to_run)
print(new_run.id)
# Change test statuses
my_project = Testrail.get_project_by_name('My Favourite Project')
some_run = my_project.runs(suites=['Master'], limit=1)[0]
for test in some_run.tests(statuses=['Untested']):
test.set_passed(comment='OK')