瀏覽代碼

Make the pagination links stable accross CI and local tests

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Pierre-Yves Chibon 6 年之前
父節點
當前提交
610db7231b

+ 5 - 4
tests/test_pagure_flask_api_group.py

@@ -123,6 +123,9 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest):
         output = self.app.get('/api/0/groups?extended=1')
         self.assertEqual(output.status_code, 200)
         data = json.loads(output.get_data(as_text=True))
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
         self.assertEqual(
             data,
             {
@@ -141,10 +144,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest):
                     }
                 ],
                 u'pagination': {
-                    u'first': u'http://localhost/api/0/groups?'
-                        'per_page=20&extended=1&page=1',
-                    u'last': u'http://localhost/api/0/groups?'
-                        'per_page=20&extended=1&page=1',
+                    u'first': u'http://localhost...',
+                    u'last': u'http://localhost...',
                     u'next': None,
                     u'page': 1,
                     u'pages': 1,

+ 134 - 46
tests/test_pagure_flask_api_issue.py

@@ -1144,6 +1144,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1160,8 +1164,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[8]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1194,6 +1198,9 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
 
         self.assertDictEqual(
             data,
@@ -1211,8 +1218,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[8]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1248,6 +1255,9 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
 
         self.assertDictEqual(
             data,
@@ -1265,8 +1275,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[8]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1286,6 +1296,9 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
 
         self.assertDictEqual(
             data,
@@ -1303,8 +1316,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[8]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1340,6 +1353,9 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
 
         self.assertDictEqual(
             data,
@@ -1357,8 +1373,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[8]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1378,6 +1394,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1394,8 +1414,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[8]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1412,6 +1432,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         data = json.loads(output.get_data(as_text=True))
         data['issues'][0]['date_created'] = '1431414800'
         data['issues'][0]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1428,8 +1452,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[0]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?status=Closed&page=1&per_page=20',
-                u'last': u'http://localhost/api/0/test/issues?status=Closed&page=1&per_page=20',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1444,6 +1468,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         output = self.app.get('/api/0/test/issues?status=Invalid', headers=headers)
         self.assertEqual(output.status_code, 200)
         data = json.loads(output.get_data(as_text=True))
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1460,8 +1488,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?status=Invalid&page=1&per_page=20',
-                u'last': u'http://localhost/api/0/test/issues?status=Invalid&page=0&per_page=20',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 0,
@@ -1479,6 +1507,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['last_updated'] = '1431414800'
             data['issues'][idx]['date_created'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1495,8 +1527,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [FULL_ISSUE_LIST[0], FULL_ISSUE_LIST[8]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?status=All&page=1&per_page=20',
-                u'last': u'http://localhost/api/0/test/issues?status=All&page=1&per_page=20',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1555,6 +1587,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['last_updated'] = '1431414800'
             data['issues'][idx]['date_created'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         expected = {
             "args": {
                 "assignee": None,
@@ -1569,8 +1605,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
             },
             "issues": [FULL_ISSUE_LIST[8]],
             u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1&order=asc',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1&order=asc',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1627,6 +1663,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         lcl_issues = copy.deepcopy(LCL_ISSUES)
         lcl_issues[0]['milestone'] = 'v1.0'
         self.assertDictEqual(
@@ -1645,8 +1685,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": lcl_issues,
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1664,6 +1704,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1680,8 +1724,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [lcl_issues[0]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&milestones=v1.0&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&milestones=v1.0&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1743,6 +1787,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         lcl_issues = copy.deepcopy(LCL_ISSUES)
         lcl_issues[0]['priority'] = 1
         self.assertDictEqual(
@@ -1761,8 +1809,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": lcl_issues,
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1780,6 +1828,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1796,8 +1848,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [lcl_issues[0]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?priority=high&page=1&per_page=20',
-                u'last': u'http://localhost/api/0/test/issues?priority=high&page=1&per_page=20',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1814,6 +1866,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1830,8 +1886,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [lcl_issues[0]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?priority=1&page=1&per_page=20',
-                u'last': u'http://localhost/api/0/test/issues?priority=1&page=1&per_page=20',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1910,6 +1966,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         lcl_issues = copy.deepcopy(LCL_ISSUES)
         lcl_issues[0]['milestone'] = 'v1.0'
         self.assertDictEqual(
@@ -1928,8 +1988,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": lcl_issues,
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1947,6 +2007,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1963,8 +2027,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [lcl_issues[1]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1&no_stones=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1&no_stones=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -1982,6 +2046,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -1998,8 +2066,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [lcl_issues[0]],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1&no_stones=0',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1&no_stones=0',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -2086,6 +2154,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2102,8 +2174,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": LCL_ISSUES,
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&page=1',
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&page=1',
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -2124,6 +2196,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2140,8 +2216,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": LCL_ISSUES,
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=1' % start,
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=1' % start,
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -2159,6 +2235,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2175,8 +2255,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": LCL_ISSUES[:1],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=1' % middle,
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=1' % middle,
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,
@@ -2194,6 +2274,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['date_created'] = '1431414800'
             data['issues'][idx]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2210,8 +2294,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
               },
               "issues": [],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=1' % final,
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=0' % final,
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 0,
@@ -2232,6 +2316,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
         for idx in range(len(data['issues'])):
             data['issues'][idx]['last_updated'] = '1431414800'
             data['issues'][idx]['date_created'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2267,8 +2355,8 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest):
                 'user': {'fullname': 'PY C', 'name': 'pingou'}}
               ],
               u'pagination': {
-                u'first': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=1' % final,
-                u'last': u'http://localhost/api/0/test/issues?per_page=20&since=%s&page=1' % final,
+                u'first': u'http://localhost...',
+                u'last': u'http://localhost...',
                 u'next': None,
                 u'page': 1,
                 u'pages': 1,

+ 36 - 12
tests/test_pagure_flask_api_ui_private_repo.py

@@ -2342,6 +2342,10 @@ class PagurePrivateRepotest(tests.Modeltests):
             data = json.loads(output.get_data(as_text=True))
             data['issues'][0]['date_created'] = '1431414800'
             data['issues'][0]['last_updated'] = '1431414800'
+            for k in ['first', 'last']:
+                self.assertIsNotNone(data['pagination'][k])
+                data['pagination'][k] = 'http://localhost...'
+
             self.assertDictEqual(
                 data,
                 {
@@ -2384,8 +2388,8 @@ class PagurePrivateRepotest(tests.Modeltests):
                         }
                     ],
                     'pagination': {
-                        u'first': u'http://localhost/api/0/test4/issues?per_page=20&page=1',
-                        u'last': u'http://localhost/api/0/test4/issues?per_page=20&page=1',
+                        u'first': u'http://localhost...',
+                        u'last': u'http://localhost...',
                         u'next': None,
                         u'page': 1,
                         u'pages': 1,
@@ -2419,6 +2423,10 @@ class PagurePrivateRepotest(tests.Modeltests):
             data['issues'][0]['last_updated'] = '1431414800'
             data['issues'][1]['date_created'] = '1431414800'
             data['issues'][1]['last_updated'] = '1431414800'
+            for k in ['first', 'last']:
+                self.assertIsNotNone(data['pagination'][k])
+                data['pagination'][k] = 'http://localhost...'
+
             self.assertDictEqual(
                 data,
                 {
@@ -2482,8 +2490,8 @@ class PagurePrivateRepotest(tests.Modeltests):
                         }
                     ],
                     'pagination': {
-                        u'first': u'http://localhost/api/0/test4/issues?per_page=20&page=1',
-                        u'last': u'http://localhost/api/0/test4/issues?per_page=20&page=1',
+                        u'first': u'http://localhost...',
+                        u'last': u'http://localhost...',
                         u'next': None,
                         u'page': 1,
                         u'pages': 1,
@@ -2510,6 +2518,10 @@ class PagurePrivateRepotest(tests.Modeltests):
         data['issues'][0]['last_updated'] = '1431414800'
         data['issues'][1]['date_created'] = '1431414800'
         data['issues'][1]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2573,8 +2585,8 @@ class PagurePrivateRepotest(tests.Modeltests):
                     }
                 ],
                 'pagination': {
-                    u'first': u'http://localhost/api/0/test4/issues?per_page=20&page=1',
-                    u'last': u'http://localhost/api/0/test4/issues?per_page=20&page=1',
+                    u'first': u'http://localhost...',
+                    u'last': u'http://localhost...',
                     u'next': None,
                     u'page': 1,
                     u'pages': 1,
@@ -2591,6 +2603,10 @@ class PagurePrivateRepotest(tests.Modeltests):
             '/api/0/test4/issues?status=Closed', headers=headers)
         self.assertEqual(output.status_code, 200)
         data = json.loads(output.get_data(as_text=True))
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2607,8 +2623,8 @@ class PagurePrivateRepotest(tests.Modeltests):
                 },
                 "issues": [],
                 'pagination': {
-                    u'first': u'http://localhost/api/0/test4/issues?status=Closed&page=1&per_page=20',
-                    u'last': u'http://localhost/api/0/test4/issues?status=Closed&page=0&per_page=20',
+                    u'first': u'http://localhost...',
+                    u'last': u'http://localhost...',
                     u'next': None,
                     u'page': 1,
                     u'pages': 0,
@@ -2624,6 +2640,10 @@ class PagurePrivateRepotest(tests.Modeltests):
             '/api/0/test4/issues?status=Invalid', headers=headers)
         self.assertEqual(output.status_code, 200)
         data = json.loads(output.get_data(as_text=True))
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2640,8 +2660,8 @@ class PagurePrivateRepotest(tests.Modeltests):
                 },
                 "issues": [],
                 'pagination': {
-                    u'first': u'http://localhost/api/0/test4/issues?status=Invalid&page=1&per_page=20',
-                    u'last': u'http://localhost/api/0/test4/issues?status=Invalid&page=0&per_page=20',
+                    u'first': u'http://localhost...',
+                    u'last': u'http://localhost...',
                     u'next': None,
                     u'page': 1,
                     u'pages': 0,
@@ -2661,6 +2681,10 @@ class PagurePrivateRepotest(tests.Modeltests):
         data['issues'][0]['last_updated'] = '1431414800'
         data['issues'][1]['date_created'] = '1431414800'
         data['issues'][1]['last_updated'] = '1431414800'
+        for k in ['first', 'last']:
+            self.assertIsNotNone(data['pagination'][k])
+            data['pagination'][k] = 'http://localhost...'
+
         self.assertDictEqual(
             data,
             {
@@ -2724,8 +2748,8 @@ class PagurePrivateRepotest(tests.Modeltests):
                     }
                 ],
                 'pagination': {
-                    u'first': u'http://localhost/api/0/test4/issues?status=All&page=1&per_page=20',
-                    u'last': u'http://localhost/api/0/test4/issues?status=All&page=1&per_page=20',
+                    u'first': u'http://localhost...',
+                    u'last': u'http://localhost...',
                     u'next': None,
                     u'page': 1,
                     u'pages': 1,

+ 32 - 16
tests/test_pagure_flask_api_user.py

@@ -71,8 +71,8 @@ class PagureFlaskApiUSertests(tests.Modeltests):
         exp = {
             "forks": [],
             'forks_pagination': {
-              'first': u'http://localhost/api/0/user/pingou?per_page=20&forkpage=1',
-              'last': u'http://localhost/api/0/user/pingou?per_page=20&forkpage=0',
+              'first': 'http://localhost...',
+              'last': 'http://localhost...',
               'next': None,
               'forkpage': 1,
               'pages': 0,
@@ -80,8 +80,8 @@ class PagureFlaskApiUSertests(tests.Modeltests):
               'prev': None},
             "repos": [],
             'repos_pagination': {
-              'first': u'http://localhost/api/0/user/pingou?per_page=20&repopage=1',
-              'last': u'http://localhost/api/0/user/pingou?per_page=20&repopage=0',
+              'first': 'http://localhost...',
+              'last': 'http://localhost...',
               'next': None,
               'repopage': 1,
               'pages': 0,
@@ -89,6 +89,10 @@ class PagureFlaskApiUSertests(tests.Modeltests):
               'prev': None},
             "user": { "fullname": "PY C", "name": "pingou"}}
         data = json.loads(output.get_data(as_text=True))
+        for k in ['forks_pagination', 'repos_pagination']:
+            for k2 in ['first', 'last']:
+                self.assertIsNotNone(data[k][k2])
+                data[k][k2] = 'http://localhost...'
         self.assertEqual(data, exp)
 
     def test_api_view_user_with_project(self):
@@ -107,11 +111,15 @@ class PagureFlaskApiUSertests(tests.Modeltests):
         data['repos'][1]['date_modified'] = "1490272832"
         data['repos'][2]['date_created'] = "1490272832"
         data['repos'][2]['date_modified'] = "1490272832"
+        for k in ['forks_pagination', 'repos_pagination']:
+            for k2 in ['first', 'last']:
+                self.assertIsNotNone(data[k][k2])
+                data[k][k2] = 'http://localhost...'
         expected_data = {
             "forks": [],
             'forks_pagination': {
-              'first': u'http://localhost/api/0/user/pingou?per_page=20&forkpage=1',
-              'last': u'http://localhost/api/0/user/pingou?per_page=20&forkpage=0',
+              'first': 'http://localhost...',
+              'last': 'http://localhost...',
               'next': None,
               'forkpage': 1,
               'pages': 0,
@@ -227,8 +235,8 @@ class PagureFlaskApiUSertests(tests.Modeltests):
                 }
             ],
             'repos_pagination': {
-              'first': u'http://localhost/api/0/user/pingou?per_page=20&repopage=1',
-              'last': u'http://localhost/api/0/user/pingou?per_page=20&repopage=1',
+              'first': 'http://localhost...',
+              'last': 'http://localhost...',
               'next': None,
               'repopage': 1,
               'pages': 1,
@@ -1081,6 +1089,10 @@ class PagureFlaskApiUsertestissues(tests.Modeltests):
         output = self.app.get('/api/0/user/foo/issues')
         self.assertEqual(output.status_code, 200)
         data = json.loads(output.get_data(as_text=True))
+        for k in ['pagination_issues_assigned', 'pagination_issues_created']:
+            for k2 in ['first', 'last']:
+                self.assertIsNotNone(data[k][k2])
+                data[k][k2] = None
         self.assertEqual(
             data,
             {
@@ -1099,16 +1111,16 @@ class PagureFlaskApiUsertestissues(tests.Modeltests):
               "issues_assigned": [],
               "issues_created": [],
               'pagination_issues_assigned': {
-                'first': u'http://localhost/api/0/user/foo/issues?per_page=20&page=1',
-                'last': u'http://localhost/api/0/user/foo/issues?per_page=20&page=0',
+                'first': None,
+                'last': None,
                 'next': None,
                 'page': 1,
                 'pages': 0,
                 'per_page': 20,
                 'prev': None},
               'pagination_issues_created': {
-                'first': u'http://localhost/api/0/user/foo/issues?per_page=20&page=1',
-                'last': u'http://localhost/api/0/user/foo/issues?per_page=20&page=0',
+                'first': None,
+                'last': None,
                 'next': None,
                 'page': 1,
                 'pages': 0,
@@ -1135,6 +1147,10 @@ class PagureFlaskApiUsertestissues(tests.Modeltests):
             issue['project']['date_modified'] = '1513111778'
             issues.append(issue)
         data['issues_created'] = issues
+        for k in ['pagination_issues_assigned', 'pagination_issues_created']:
+            for k2 in ['first', 'last']:
+                self.assertIsNotNone(data[k][k2])
+                data[k][k2] = None
         self.assertEqual(
             data,
             {
@@ -1215,16 +1231,16 @@ class PagureFlaskApiUsertestissues(tests.Modeltests):
                 }
               ],
               'pagination_issues_assigned': {
-                'first': u'http://localhost/api/0/user/pingou/issues?per_page=20&page=1',
-                'last': u'http://localhost/api/0/user/pingou/issues?per_page=20&page=0',
+                'first': None,
+                'last': None,
                 'next': None,
                 'page': 1,
                 'pages': 0,
                 'per_page': 20,
                 'prev': None},
               'pagination_issues_created': {
-                'first': u'http://localhost/api/0/user/pingou/issues?per_page=20&page=1',
-                'last': u'http://localhost/api/0/user/pingou/issues?per_page=20&page=1',
+                'first': None,
+                'last': None,
                 'next': None,
                 'page': 1,
                 'pages': 1,