4 # Copyright (C) 2007, 2008 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """Script for unittesting the rapi.resources module"""
28 from ganeti.rapi import resources
31 class MapperTests(unittest.TestCase):
34 self.con = resources.CONNECTOR
35 self.map = resources.Mapper(self.con)
38 """Testing for Mapper."""
40 self.failUnless(self.map.getController('/tags') ==
45 self.failUnless(self.map.getController('/tag') == None)
47 self.failUnless(self.map.getController('/instances/www.test.com') ==
52 self.failUnless(self.map.getController(
53 '/instances/www.test.com/tags?f=5&f=6&alt=html') ==
54 ('R_instances_name_tags',
56 {'alt':['html'], 'f':['5', '6']}))
59 class R_RootTests(unittest.TestCase):
60 """Testing for R_root class."""
63 self.root = resources.R_root(None, None, None)
68 self.failUnless(self.root.result ==
69 [{'name': 'instances', 'uri': '/instances'},
70 {'name': 'info', 'uri': '/info'},
71 {'name': 'os', 'uri': '/os'},
72 {'name': 'status', 'uri': '/status'},
73 {'name': 'tags', 'uri': '/tags'},
74 {'name': 'nodes', 'uri': '/nodes'}])
77 if __name__ == '__main__':