Skip to content

Commit

Permalink
Fixed to get attachment's url for another ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
t2y committed Nov 2, 2014
1 parent aa72487 commit 006b73d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions trunk/movie/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def parse_imagemacro_style(url, path_info):
(u'ticket', u'1', u'file.ext')
>>> parse_imagemacro_style(u'ticket:1:file.ext', u'/ticket/1')
(u'ticket', u'1', u'file.ext')
>>> parse_imagemacro_style(u'ticket:2:file.ext', u'/ticket/1')
(u'ticket', u'2', u'file.ext')
>>> parse_imagemacro_style(u'file.ext', u'/wiki/start')
(u'wiki', u'start', u'file.ext')
>>> parse_imagemacro_style(u'file.ext', u'/wiki/start/sub/deep')
Expand All @@ -106,6 +108,9 @@ def parse_imagemacro_style(url, path_info):
_path = '/'.join(_path_info[2:])

_url = url.split(':')
if scheme == 'ticket' and len(_url) == 3:
netloc = _url[1]

path = _url[-1]
if scheme != 'ticket':
if len(_url) == 1:
Expand Down
2 changes: 2 additions & 0 deletions trunk/tests/test_macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def test_get_absolute_url(movie_macro, url, expected):
'%s/raw-attachment/ticket/123/sample.webm' % BASE_HREF),
('ticket:123:sample.webm', u'/ticket/123',
'%s/raw-attachment/ticket/123/sample.webm' % BASE_HREF),
('ticket:456:sample.webm', u'/ticket/123',
'%s/raw-attachment/ticket/456/sample.webm' % BASE_HREF),
('wiki:sample.mp4', u'/wiki/page',
'%s/raw-attachment/wiki/page/sample.mp4' % BASE_HREF),
('wiki:page/sample.mp4', u'/wiki/page',
Expand Down
1 change: 1 addition & 0 deletions trunk/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_set_default_parameters(param, default, kwargs, expected):
@pytest.mark.parametrize(('url', 'path_info', 'expected'), [
('file.ext', '/ticket/1', ('ticket', '1', 'file.ext')),
('ticket:1:file.ext', '/ticket/1', ('ticket', '1', 'file.ext')),
('ticket:2:file.ext', '/ticket/1', ('ticket', '2', 'file.ext')),
('file.ext', '/wiki/start', ('wiki', 'start', 'file.ext')),
('file.ext', '/wiki/start/sub/deep',
('wiki', 'start', 'sub/deep/file.ext')),
Expand Down

0 comments on commit 006b73d

Please sign in to comment.