Skip to content

Commit 64eb1df

Browse files
authored
Merge pull request #16 from kmaehashi/update-tag-list-apis
Update URI API
2 parents 17b7614 + da05aab commit 64eb1df

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

atwiki/test/test_uri.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ def test_path_output(self):
3030
self.assertEqual(uri.search('test', is_and=False), '{0}/?cmd=search&keyword=test&andor=or&search_field=&cmp=cmp'.format(base))
3131
self.assertEqual(uri.search('test', wiki_syntax=True), '{0}/?cmd=search&keyword=test&andor=and&search_field=source&cmp=cmp'.format(base))
3232
self.assertEqual(uri.search('test', complete=False), '{0}/?cmd=search&keyword=test&andor=and&search_field=&cmp='.format(base))
33-
self.assertEqual(uri.tag(), '{0}/tag/?p=0'.format(base))
34-
self.assertEqual(uri.tag('test'), '{0}/tag/test?p=0'.format(base))
35-
self.assertEqual(uri.tag('test', 1), '{0}/tag/test?p=1'.format(base))
33+
self.assertEqual(uri.tags(), '{0}/tag/?sort=&p=1'.format(base))
34+
self.assertEqual(uri.tags('num', 2), '{0}/tag/?sort=num&p=2'.format(base))
35+
self.assertEqual(uri.tag(), '{0}/tag/?p=1'.format(base)) # deprecated
36+
self.assertEqual(uri.tag('test'), '{0}/tag/test?p=1'.format(base))
37+
self.assertEqual(uri.tag('test', 2), '{0}/tag/test?p=2'.format(base))
3638
self.assertEqual(uri.new(), '{0}/new'.format(base))
37-
self.assertEqual(uri.list(), '{0}/list?sort=update&pp=0'.format(base))
38-
self.assertEqual(uri.list('create'), '{0}/list?sort=create&pp=0'.format(base))
39-
self.assertEqual(uri.list('create', 1), '{0}/list?sort=create&pp=1'.format(base))
39+
self.assertEqual(uri.list(), '{0}/list?sort=update&pp=1'.format(base))
40+
self.assertEqual(uri.list('create'), '{0}/list?sort=create&pp=1'.format(base))
41+
self.assertEqual(uri.list('create', 2), '{0}/list?sort=create&pp=2'.format(base))
4042
self.assertEqual(uri.contact(), '{0}/contact'.format(base))
4143

4244
self.assertEqual(uri.backup_list(), '{0}/?cmd=backup&action=list'.format(base))

atwiki/uri.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,21 @@ def search(self, keyword=None, is_and=True, wiki_syntax=False, complete=True):
6262
else:
6363
return '{0}/search'.format(self._base)
6464

65-
def tag(self, tag_name='', index=0):
65+
def tags(self, sort='', index=1):
66+
return '{}/tag/?sort={}&p={}'.format(self._base, sort, index)
67+
68+
def tag(self, tag_name='', index=1):
69+
if tag_name == '':
70+
warnings.warn(
71+
'Specifying empty string to tag_name to get URL for list of tags is deprecated.'
72+
' Use .tags() instead.',
73+
DeprecationWarning)
6674
return '{0}/tag/{1}?p={2}'.format(self._base, urlquote(tag_name), index)
6775

6876
def new(self):
6977
return '{0}/new'.format(self._base)
7078

71-
def list(self, sort='update', index=0):
79+
def list(self, sort='update', index=1):
7280
"""
7381
``sort`` can be any of ``update``, ``create``, ``create_desc`` or ``pagename``.
7482
"""

0 commit comments

Comments
 (0)