Merge lp:~rvb/maas/network-listing-pagination into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 2166
Proposed branch: lp:~rvb/maas/network-listing-pagination
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 44 lines (+16/-1)
2 files modified
src/maasserver/templates/maasserver/network_list.html (+1/-0)
src/maasserver/views/tests/test_networks.py (+15/-1)
To merge this branch: bzr merge lp:~rvb/maas/network-listing-pagination
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+212579@code.launchpad.net

Commit message

Fix network listing: add pagination.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Paginated network listings? Somebody has been shopping for hardware. :-)

The output on that final test assertion is a nice touch.

I'm not usually one to argue against comments and documentation, but, in lines 35 and 36 of the diff:

        # Create 4 networks.
        factory.make_networks(4)

Duh. :) Probably doesn't need the comment.

And in lines 38 and 39:

        self.assertEqual(
            httplib.OK, response.status_code, response.content)

Test failures show response content now, so no more need to pass it to the assertion!

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> Paginated network listings? Somebody has been shopping for hardware. :-)
>
> The output on that final test assertion is a nice touch.
>
> I'm not usually one to argue against comments and documentation, but, in lines
> 35 and 36 of the diff:
>
> # Create 4 networks.
> factory.make_networks(4)
>
> Duh. :) Probably doesn't need the comment.
>
> And in lines 38 and 39:
>
> self.assertEqual(
> httplib.OK, response.status_code, response.content)
>
> Test failures show response content now, so no more need to pass it to the
> assertion!

All done, thanks for the review!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/templates/maasserver/network_list.html'
2--- src/maasserver/templates/maasserver/network_list.html 2014-02-24 07:48:20 +0000
3+++ src/maasserver/templates/maasserver/network_list.html 2014-03-25 11:23:12 +0000
4@@ -75,6 +75,7 @@
5 {% endfor %}
6 </tbody>
7 </table>
8+ {% include "maasserver/pagination.html" %}
9 {% else %}
10 No networks defined.
11 {% endif %}
12
13=== modified file 'src/maasserver/views/tests/test_networks.py'
14--- src/maasserver/views/tests/test_networks.py 2014-02-24 07:50:40 +0000
15+++ src/maasserver/views/tests/test_networks.py 2014-03-25 11:23:12 +0000
16@@ -30,7 +30,10 @@
17 from maasserver.testing.factory import factory
18 from maasserver.testing.testcase import MAASServerTestCase
19 from maasserver.utils.orm import get_one
20-from maasserver.views.networks import NetworkAdd
21+from maasserver.views.networks import (
22+ NetworkAdd,
23+ NetworkListView,
24+ )
25 from testtools.matchers import (
26 Contains,
27 ContainsAll,
28@@ -101,6 +104,17 @@
29 [link for link in get_content_links(response)
30 if link.startswith('/nodes/')])
31
32+ def test_network_listing_is_paginated(self):
33+ self.patch(NetworkListView, "paginate_by", 3)
34+ self.client_log_in(as_admin=True)
35+ factory.make_networks(4)
36+ response = self.client.get(reverse('network-list'))
37+ self.assertEqual(httplib.OK, response.status_code)
38+ doc = fromstring(response.content)
39+ self.assertEqual(
40+ 1, len(doc.cssselect('div.pagination')),
41+ "Couldn't find pagination tag.")
42+
43
44 class NetworkListingViewTestNonAdmin(MAASServerTestCase):
45