Skip to content

Commit 6008d95

Browse files
committed
Merge branch 'release/2.30.0'
2 parents c54869d + e055ecb commit 6008d95

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

backslash/contrib/slash_plugin.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,22 @@ def rest_url(self):
7979

8080
@property
8181
def webapp_url(self):
82+
return self._url_with_fragment('/')
83+
84+
@property
85+
def session_webapp_url(self):
86+
session = slash.context.session
87+
if session is None:
88+
return None
89+
return self._url_with_fragment('sessions/{}'.format(session.id))
90+
91+
def _url_with_fragment(self, fragment):
8292
returned = str(self._get_backslash_url())
8393
if not returned.endswith('/'):
8494
returned += '/'
85-
returned += '#/'
95+
if not fragment.startswith('/'):
96+
fragment = '/' + fragment
97+
returned += '#{}'.format(fragment)
8698
return returned
8799

88100
def _handle_exception(self, exc_info):

docs/changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Changelog
22
=========
33

4-
* :release:`2.29.0 <6-7-2017>`
4+
* :release: `2.30.0 <8-8-2017>`
5+
* :feature:`50` Added session_webapp_url property to the Slash plugin
6+
* :release:`2.29.0 <6-8-2017>`
57
* :feature:`49` Add hook for intercepting keepalive thread exceptions
68
* :feature:`-` Move to PBR
79
* :bug:`31 major` Be more resilient to I/O errors when compressing tracebacks

tests/test_slash_plugin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ def test_webapp_url(installed_plugin, server_url):
4040
expected += '#/'
4141
assert installed_plugin.webapp_url == expected
4242

43+
def test_session_webapp_url_no_session(installed_plugin):
44+
assert installed_plugin.session_webapp_url is None
45+
46+
def test_session_webapp_url_with_session(installed_plugin, server_url):
47+
with slash.Session() as s:
48+
url = installed_plugin.session_webapp_url
49+
assert url == '{}/#/sessions/{}'.format(server_url, s.id)
50+
51+
52+
4353

4454

4555
@pytest.fixture

0 commit comments

Comments
 (0)