~julian-edwards/maas/nodegroup-on-bootimage-schema

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_api.py

  • Committer: Tarmac
  • Author(s): Raphael Badin
  • Date: 2012-10-19 14:12:29 UTC
  • mfrom: (1287.2.8 bulk-load)
  • Revision ID: tarmac-20121019141229-zqiodlexfafvxxqs
[r=allenap][bug=1066775][author=rvb] Load the mac addresses related to a node from the cache even if .iterator() is used.  Preload the macaddresses and the tags related to a list of nodes when fetching the list of nodes via the api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1657
1657
            [node1.system_id, node2.system_id],
1658
1658
            extract_system_ids(parsed_result))
1659
1659
 
 
1660
    def create_nodes(self, nodegroup, nb):
 
1661
        [factory.make_node(nodegroup=nodegroup, mac=True)
 
1662
            for i in range(nb)]
 
1663
 
 
1664
    def test_GET_list_nodes_issues_constant_number_of_queries(self):
 
1665
        nodegroup = factory.make_node_group()
 
1666
        self.create_nodes(nodegroup, 10)
 
1667
        num_queries1, response1 = self.getNumQueries(
 
1668
            self.client.get, self.get_uri('nodes/'), {'op': 'list'})
 
1669
        self.create_nodes(nodegroup, 10)
 
1670
        num_queries2, response2 = self.getNumQueries(
 
1671
            self.client.get, self.get_uri('nodes/'), {'op': 'list'})
 
1672
        # Make sure the responses are ok as it's not useful to compare the
 
1673
        # number of queries if they are not.
 
1674
        self.assertEqual(
 
1675
            [httplib.OK, httplib.OK, 10, 20],
 
1676
            [
 
1677
                response1.status_code,
 
1678
                response2.status_code,
 
1679
                len(extract_system_ids(json.loads(response1.content))),
 
1680
                len(extract_system_ids(json.loads(response2.content))),
 
1681
            ])
 
1682
        self.assertEqual(num_queries1, num_queries2)
 
1683
 
1660
1684
    def test_GET_list_without_nodes_returns_empty_list(self):
1661
1685
        # If there are no nodes to list, the "list" op still works but
1662
1686
        # returns an empty list.