-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
59 lines (42 loc) · 1.9 KB
/
conftest.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
import pytest
import requests
from datetime import datetime
from pytest_metadata.plugin import metadata_key
passed_count = 0
failed_count = 0
skipped_count = 0
total_count = 0
def pytest_configure(config):
config.stash[metadata_key]["Test Executed By"] = "Deekshith"
def pytest_html_report_title(report):
report.title = "Test-Report"
def pytest_html_results_summary(prefix, summary, postfix):
prefix.extend(["<p>Suite Description: API testing of IDOCX API's</p>"])
def pytest_html_results_table_header(cells):
cells.insert(2, "<th>Description</th>")
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
global passed_count, failed_count, skipped_count, total_count
outcome = yield
report = outcome.get_result()
report.description = item.function.__doc__
if call.when == 'call':
total_count += 1
if call.excinfo is None:
passed_count += 1
elif call.excinfo.errisinstance(pytest.skip.Exception):
skipped_count += 1
else:
failed_count += 1
def pytest_html_results_table_row(report, cells):
if hasattr(report, "description"):
cells.insert(2, f"<td>{report.description}</td>")
else:
cells.insert(2, "<td>No description available</td>")
@pytest.fixture(scope='session', autouse=True)
def final_cleanup(request):
yield
current_date_time = datetime.now().strftime("%m-%d-%Y %I:%M:%S %p")
message = f'[b]Regression Testing Summary for IDOCX[/b]%0ADate: {current_date_time}%0A%0APassed: {passed_count}%0AFailed: {failed_count}%0ASkipped: {skipped_count}%0ATotal Test Cases: {total_count}'
requests.get(f'https://sirmaglobal.bitrix24.com/rest/118/b2iecuj66krfw9kk/imbot.message.add.json?BOT_ID=214&CLIENT_ID=6gvjn227c5aayn2qo6ur6e16rpbwtn4r&DIALOG_ID=216&MESSAGE={message}')
print("Bitrix Notification Sent!")