-
Notifications
You must be signed in to change notification settings - Fork 0
/
BackslashPlugin.py
71 lines (54 loc) · 2.67 KB
/
BackslashPlugin.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
from slash import plugins
from backslash import Backslash as BackslashClient
from slash.ctx import context
from urlobject import URLObject
import slash
import gossip
class BackslashPlugin(plugins.PluginInterface):
def __init__(self):
self.current_session = None
self.current_test = None
def get_name(self):
return "backslash"
def configure_argument_parser(self, parser):
parser.add_argument(
"-s", "--server-address", help="IP Address of backslash server")
def configure_from_parsed_args(self, args):
if args.server_address:
self.server_address = URLObject(args.server_address)
else:
self.server_address = URLObject(slash.config.root.backslash.serverAddress)
def session_start(self):
self.client = BackslashClient(self.server_address)
self.current_session = self.client.report_session_start(
logical_id=context.session.id)
gossip.trigger('backslash.report_session_start', started_session=self.current_session)
def session_end(self):
if self.current_session:
self.current_session.report_end()
def test_start(self):
self.current_test = self.current_session.report_test_start(
test_logical_id=context.test.__slash__.id, name=str(context.test))
gossip.trigger('backslash.report_test_start', started_test=self.current_test)
def test_end(self):
self.current_test.report_end()
gossip.trigger('backslash.report_test_end', ended_test=self.current_test)
self.current_test = None
def error_added(self, error, result):
if self.current_test is None: # session error
if self.current_session is None:
return # it's even before a session exist - nowhere to report it
# (+ there won't be an entry in Backslash so it's OK)
self.current_session.add_error_data(exception=error.exception.message,
exception_type=error.exception_type.__name__,
traceback=error.traceback.to_list(),
timestamp=error.time.timestamp)
return
self.current_test.add_error_data(exception=error.exception.message,
exception_type=error.exception_type.__name__,
traceback=error.traceback.to_list(),
timestamp=error.time.timestamp)
def test_interrupt(self):
self.current_test.mark_interrupted()
def test_skip(self, reason):
self.current_test.mark_skipped()