Skip to content

Commit 5794465

Browse files
committed
Merge branch 'feature/plugin_url' into develop
2 parents 37ebb2d + bc30c07 commit 5794465

3 files changed

Lines changed: 56 additions & 6 deletions

File tree

backslash/contrib/slash_plugin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ def __init__(self, url=None, keepalive_interval=None, runtoken=None, propagate_e
7373
self._runtoken = runtoken
7474
self._propagate_exceptions = propagate_exceptions
7575

76+
@property
77+
def rest_url(self):
78+
return URL(self._url).add_path('rest')
79+
80+
@property
81+
def webapp_url(self):
82+
returned = str(self._url)
83+
if not returned.endswith('/'):
84+
returned += '/'
85+
returned += '#/'
86+
return returned
87+
7688
def _handle_exception(self, exc_info):
7789
pass
7890

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Changelog
22
=========
33

44
* :bug:`31 major` Be more resilient to I/O errors when compressing tracebacks
5+
* :feature:`39` Added ``webapp_url`` and ``rest_url`` to the official Slash plugin
56
* :feature:`37` Support reporting fatal exceptions
67
* :feature:`36` Added ``get_parent`` to test objects to retrieve the parent session
78
* :release:`2.28.0 <15-05-2017>`

tests/test_slash_plugin.py

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,80 @@
11
import pytest
2+
from urlobject import URLObject
23
import slash
34
import slash.loader
45

56
from backslash.contrib.utils import distill_slash_traceback
67

78
# pylint: disable=redefined-outer-name
89

10+
911
def test_importing_slash_plugin():
1012
from backslash.contrib import slash_plugin # pylint: disable=unused-variable
1113

14+
1215
def test_exception_distilling(traceback):
1316
assert isinstance(traceback, list)
1417
assert traceback
1518
for f in traceback:
1619
assert f['code_line']
1720

21+
1822
def test_exception_distilling_surrounding_code(traceback):
1923
frame = traceback[-1]
20-
assert 'def test_failing():' in [line.strip() for line in frame['code_lines_before']]
21-
assert '1/0' in frame['code_line']
24+
assert 'def test_failing():' in [line.strip()
25+
for line in frame['code_lines_before']]
26+
assert '1 / 0' in frame['code_line']
2227
assert frame['code_lines_before']
23-
assert not any('1/0' in l for l in frame['code_lines_before'])
28+
assert not any('1 / 0' in l for l in frame['code_lines_before'])
2429
assert frame['code_lines_after']
25-
assert not any('1/0' in l for l in frame['code_lines_after'])
30+
assert not any('1 / 0' in l for l in frame['code_lines_after'])
31+
32+
33+
def test_rest_url(installed_plugin, server_url):
34+
assert installed_plugin.rest_url == server_url.add_path('rest')
35+
36+
def test_webapp_url(installed_plugin, server_url):
37+
expected = server_url
38+
if not expected.endswith('/'):
39+
expected += '/'
40+
expected += '#/'
41+
assert installed_plugin.webapp_url == expected
42+
2643

2744

2845
@pytest.fixture
2946
def traceback(error_result):
3047
[e] = error_result.get_errors()
3148
return distill_slash_traceback(e)
3249

50+
3351
@pytest.fixture
3452
def error_result():
3553

3654
def test_failing():
37-
1/0 # pylint: disable=pointless-statement
55+
1 / 0 # pylint: disable=pointless-statement
3856

3957
with slash.Session() as s:
4058
with s.get_started_context():
41-
slash.runner.run_tests(slash.loader.Loader().get_runnables([test_failing]))
59+
slash.runner.run_tests(
60+
slash.loader.Loader().get_runnables([test_failing]))
4261
[res] = s.results.iter_test_results()
4362
return res
63+
64+
65+
@pytest.fixture
66+
def installed_plugin(request, server_url):
67+
from backslash.contrib import slash_plugin
68+
plugin = slash_plugin.BackslashPlugin(url=str(server_url))
69+
70+
@request.addfinalizer
71+
def cleanup(): # pylint: disable=unused-variable
72+
slash.plugins.manager.uninstall(plugin)
73+
74+
slash.plugins.manager.install(plugin)
75+
return plugin
76+
77+
78+
@pytest.fixture
79+
def server_url():
80+
return URLObject('http://some.backslash.server')

0 commit comments

Comments
 (0)