def test_read_host_with_items(self): r = request.Request.blank(path='/argux/rest/1.0/host/localhost?items=true') r.registry = Registry() r.registry.settings = {} r.registry.settings['dao'] = dao.DAO() r.matchdict = {'host':'localhost','item':'NONE'} v = RestHostViews(r) response = v.host_1_view_get('localhost') # Check if 'name' is part of the response self.assertEquals(('name' in response), True) # Check if 'items' is part of the response self.assertEquals(('items' in response), True) # Check if 'details' is part of the response self.assertEquals(('details' in response), True) # Check if the correct hostname is returned self.assertEqual(response['name'], 'localhost') # Check if the nr of items is 1 self.assertEqual(len(response['items']), 1) # Check if the nr of details is 0 self.assertEqual(len(response['details']), 0) # Check the contents of the items. items = response['items'] self.assertEqual(items[0]['name'], 'CPU Load Average') self.assertEqual(items[0]['key'], 'cpu.load.avg[1]') self.assertEqual(items[0]['last_val'], '42')
def test_read_host(self): r = request.Request.blank(path='/argux/rest/1.0/host/localhost') r.registry = Registry() r.registry.settings = {} r.registry.settings['dao'] = dao.DAO() r.matchdict = {'host':'localhost','item':'NONE'} v = RestHostViews(r) response = v.host_1_view_get('localhost') # Check if 'name' is part of the response self.assertEquals(('name' in response), True) # Check if 'items' is part of the response self.assertEquals(('items' in response), True) # Check if 'details' is part of the response self.assertEquals(('details' in response), True) # Check if the correct hostname is returned self.assertEqual(response['name'], 'localhost') # Check if the nr of items is 0 self.assertEqual(len(response['items']), 0) # Check if the nr of details is 0 self.assertEqual(len(response['details']), 0)