Beispiel #1
0
 def test_get_details_calls_correct_api_and_parses_result(self):
     client = self.fake_client()
     data = {
         "system-1": {
             "lshw": b"<lshw><data1 /></lshw>",
             "lldp": b"<lldp><data1 /></lldp>",
         },
         "system-2": {
             "lshw": b"<lshw><data2 /></lshw>",
             "lldp": b"<lldp><data2 /></lldp>",
         },
     }
     response1 = factory.make_response(
         http.client.OK,
         bson.BSON.encode(data["system-1"]),
         "application/bson",
     )
     response2 = factory.make_response(
         http.client.OK,
         bson.BSON.encode(data["system-2"]),
         "application/bson",
     )
     get = self.patch(client, "get")
     get.side_effect = [response1, response2]
     result = tags.get_details_for_nodes(client, ["system-1", "system-2"])
     self.assertEqual(data, result)
     self.assertThat(
         get,
         MockCallsMatch(
             call("/MAAS/api/2.0/nodes/system-1/", op="details"),
             call("/MAAS/api/2.0/nodes/system-2/", op="details"),
         ),
     )
Beispiel #2
0
 def test_get_details_calls_correct_api_and_parses_result(self):
     client, uuid = self.fake_cached_knowledge()
     data = {
         "system-1": {
             "lshw": bson.binary.Binary(b"<lshw><data1 /></lshw>"),
             "lldp": bson.binary.Binary(b"<lldp><data1 /></lldp>"),
         },
         "system-2": {
             "lshw": bson.binary.Binary(b"<lshw><data2 /></lshw>"),
             "lldp": bson.binary.Binary(b"<lldp><data2 /></lldp>"),
         },
     }
     content = bson.BSON.encode(data)
     response = make_response(httplib.OK, content, 'application/bson')
     post = self.patch(client, 'post')
     post.return_value = response
     result = tags.get_details_for_nodes(client, uuid,
                                         ['system-1', 'system-2'])
     self.assertEqual(data, result)
     url = '/api/1.0/nodegroups/%s/' % (uuid, )
     post.assert_called_once_with(url,
                                  op='details',
                                  system_ids=["system-1", "system-2"])