예제 #1
0
def main():
    # Declare TestRail API
    testrail_api = APIClient(TESTRAIL_URL)
    testrail_api.user = TESTRAIL_EMAIL_ADDRESS
    testrail_api.password = TESTRAIL_API_TOKEN

    # Retrieve all sections for the project
    all_sections = testrail_api.send_get('get_sections/' + str(PROJECT_ID))

    # all_results will hold all test results and will be the body of the result submission to TestRail
    all_results = dict()
    all_results['results'] = list()
    all_results['results'] += run_tests(all_sections, testrail_api)

    # Create test run
    new_run = testrail_api.send_post('add_run/' + str(PROJECT_ID), {
        "name": "Webinar Math Tests",
        "include_all": True
    })
    # add results
    run_results = testrail_api.send_post(
        'add_results_for_cases/' + str(new_run['id']), all_results)

    # Close test run
    testrail_api.send_post('close_run/' + str(new_run['id']), {})

    # Display some stuff
    # print(all_results)
    print('Testing Complete!\nResults available here: ' + TESTRAIL_URL +
          'index.php?/runs/view/' + str(new_run['id']))
    pass
예제 #2
0
    def __init__(self, username='', password='', url=''):
        self.username = username
        self.password = password
        self.url = url

        if not username:
            self.username = settings.USR
        if not password:
            self.password = settings.PWD
        if not url:
            self.url = settings.URL

        client = APIClient(self.url)
        client.user = self.username
        client.password = self.password

        self.client = client
        self.parser = None
예제 #3
0
import sys
import getpass
import json
import pprint
from testrail import APIClient

url = 'https://bsro.testrail.net'
client = APIClient(url)
client.user = '******'
client.password = sys.argv[1]

#def usage():
#  print("[!] Usage: tr_conn.py -p password")
#  for eachArg in sys.argv:
#        print(eachArg)


def get_creds():
    print("[<] Enter TestRail login:\n")
    if len(client.user) < 1:
        client.user = input("login: "******"[ha!] forgot something?....where's the password ?")
            sys.exit(0)

    print("[.] k, got the creds for ", client.user)


def input_yes_no(question, default="yes"):
예제 #4
0
                    action='store',
                    dest='tpid',
                    help='TestRail test plan ID, ex. R2330 ',
                    required=True)
parser.add_argument(
    '--url',
    action='store',
    dest='url',
    help='TestRail url, default set to https://bsro.testrail.net',
    default='https://bsro.testrail.net')
results = parser.parse_args()

url = results.url
client = APIClient(url)
client.user = results.username
client.password = results.password
tpid_argv = results.tpid[1:]


def get_creds():
    if len(client.user) < 1:
        client.user = input("login: "******"[ha!] forgot something?....where's the password ?")
            sys.exit(0)
    print("[.] k, got the creds for ", client.user)


def input_yes_no(question, default="yes"):
예제 #5
0
from creds import *
from testrail import APIClient
import sys
import datetime

client = APIClient(TESTRAIL_URL)
client.user = TESTRAIL_USER
client.password = TESTRAIL_API_TOKEN

RUN_ID = 371
project_id = 0
status_styles = {}


def make_report(test_run_id):
    indent = 1

    html_output = ''

    # Import structured header info
    with open('html_headers.html', 'r') as head_file:
        html_output += head_file.read()

    # Add body of html details
    html_output += get_run_info(test_run_id, indent + 1)

    # Add closing html elements
    html_output += close_element('div', indent)
    html_output += close_element('body', 0)
    html_output += close_element('html', 0)
예제 #6
0
def get_testrail_client():
    client = APIClient(TESTRAIL_URL)
    client.user = TESTRAIL_USER
    client.password = TESTRAIL_PASSWORD

    return client
from testrail import APIClient
import sys

#connection information
client = APIClient('https://testplant.testrail.net/')
client.user = '******'
client.password = '******'

#open the RunHistory.csv file, then check if the last line includes the word "Success"
#(The latest result is in the last line)
#f = open('C:/Workspaces/ePF/TestRailSample/TestRail_sample.suite/Results/main/RunHistory.csv')
resultFolder = sys.argv[1]
print resultFolder
sys.exit()

lastLine = f.readlines()[-1] # Read the last line of the results file
f.close()
fields = lastLine.split(',') # Split the line into comma separated fields

if len(fields) != 10:
	print("Error: Last line of RunHistory has fewer than 10 fields")
	sys.exit()

if fields[1].find('Success') >= 0:
    print ('Last Run: Success')

    result = client.send_post(
        'add_result_for_case/1/1',
        {'status_id': 1, 'comment': fields[8]}
    )
elif fields[1].find ('Failure') > 0:
예제 #8
0
from pprint import pprint
import json
from testrail import APIClient, APIError

import requests

client = APIClient('')
client.user = ''
client.password = ''


class TestRailClient:
    def add_result(self, test_id, status: str):
        _ = client.send_post(f'add_result/{test_id}', {"status_id": 5})

    def add_result_for_case(self, run_id: int, case_id: int, status: str,
                            msg: str):
        """Add test case and update result

        """
        if status.lower() == "pass":
            result = client.send_post(
                'add_result_for_case/%d/%d' % (run_id, case_id), {
                    'status_id': 1,
                    'comment': msg
                })
            return result
        elif status.lower() == "fail":
            result = client.send_post(
                'add_result_for_case/%d/%d' % (run_id, case_id), {
                    'status_id': 5,
예제 #9
0
def main():
    server = "http://SERVER.COM"
    login = "******"
    password = "******"

    START_DATE = "01/08/2018"
    END_DATE = "31/08/2018"

    TESTERS = ['USER1EMAIL', 'USER2EMAIL']

    start_date = mktime(datetime.strptime(START_DATE, "%d/%m/%Y").timetuple())
    end_date = mktime(datetime.strptime(END_DATE, "%d/%m/%Y").timetuple())

    client = APIClient(server)
    client.user = login
    client.password = password

    print "Getting testers... "
    testers = {}
    for tester_email in TESTERS:
        try:
            tester = client.send_get('get_user_by_email&email={}'.format(tester_email))
            testers.update({
                tester["id"]: {
                    'email': tester_email,
                    'created': 0,
                    'updated': 0
                }
            })
        except APIError:
            print "Tester's email is not valid", tester_email

    projects = client.send_get('get_projects/')
    for project in projects:
        print "=" * 80
        print "PROJECT", project["id"]

        project_id = project["id"]
        project_suites = client.send_get('get_suites/{}'.format(project_id))

        for suite in project_suites:
            print "-" * 80
            print "SUITE", suite["id"]

            suite_id = suite["id"]

            created = client.send_get(
                'get_cases/{0}&suite_id={1}&created_after={2}&created_before={3}'.format(
                    project_id, suite_id, int(start_date), int(end_date)))

            updated = client.send_get(
                'get_cases/{0}&suite_id={1}&updated_after={2}&updated_before={3}'.format(
                    project_id, suite_id, int(start_date), int(end_date)))

            for c in created:
                tid = c['created_by']
                if tid in testers:
                    testers[tid]['created'] += 1
                # import pdb; pdb.set_trace()

            for c in updated:
                tid = c['updated_by']
                if tid in testers:
                    testers[tid]['updated'] += 1

    # ------------------------------------------------------------------------

    print "=" * 80
    pprint(testers)
def testrail_requester():
    config = load_configuration()
    client = APIClient("https://dromeroa.testrail.io")
    client.user = "******"
    client.password = config["TESTRAIL_TOKEN"]
    return client