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.map = resources.Mapper()
36 def _TestUri(self, uri, result):
37 self.assertEquals(self.map.getController(uri), result)
40 """Testing resources.Mapper"""
42 self._TestUri("/tags", (resources.R_tags, [], {}))
43 self._TestUri("/tag", None)
45 self._TestUri('/instances/www.test.com',
46 (resources.R_instances_name,
50 self._TestUri('/instances/www.test.com/tags?f=5&f=6&alt=html',
51 (resources.R_instances_name_tags,
58 class R_RootTests(unittest.TestCase):
59 """Testing for R_root class."""
62 self.root = resources.R_root(None, None, None)
67 {'name': 'info', 'uri': '/info'},
68 {'name': 'instances', 'uri': '/instances'},
69 {'name': 'nodes', 'uri': '/nodes'},
70 {'name': 'os', 'uri': '/os'},
71 {'name': 'status', 'uri': '/status'},
72 {'name': 'tags', 'uri': '/tags'},
75 self.assertEquals(self.root.result, expected)
78 if __name__ == '__main__':