| Line | |
|---|
| 1 | import unittest |
|---|
| 2 | |
|---|
| 3 | import xen.xend.sxp |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | class test_sxp(unittest.TestCase): |
|---|
| 7 | |
|---|
| 8 | def testAllFromString(self): |
|---|
| 9 | def t(inp, expected): |
|---|
| 10 | self.assertEqual(xen.xend.sxp.all_from_string(inp), expected) |
|---|
| 11 | |
|---|
| 12 | t('String', ['String']) |
|---|
| 13 | t('(String Thing)', [['String', 'Thing']]) |
|---|
| 14 | t('(String) (Thing)', [['String'], ['Thing']]) |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | def testParseFixed(self): |
|---|
| 18 | fin = file('../xen/xend/tests/xend-config.sxp', 'rb') |
|---|
| 19 | try: |
|---|
| 20 | config = xen.xend.sxp.parse(fin) |
|---|
| 21 | self.assertEqual( |
|---|
| 22 | xen.xend.sxp.child_value( |
|---|
| 23 | config, |
|---|
| 24 | 'xend-relocation-hosts-allow'), |
|---|
| 25 | '^localhost$ ^localhost\\.localdomain$') |
|---|
| 26 | finally: |
|---|
| 27 | fin.close() |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | def testParseConfigExample(self): |
|---|
| 31 | fin = file('../../examples/xend-config.sxp', 'rb') |
|---|
| 32 | try: |
|---|
| 33 | config = xen.xend.sxp.parse(fin) |
|---|
| 34 | finally: |
|---|
| 35 | fin.close() |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | def test_suite(): |
|---|
| 39 | return unittest.makeSuite(test_sxp) |
|---|
Note: See
TracBrowser
for help on using the repository browser.