1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# -*- coding: UTF-8 -*-
# Copyright 2014 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
"""Testing direct command run (e.g., when clufter used as a library)"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
import unittest
from os.path import dirname, exists, join
#from os import unlink
import _bootstrap
from clufter.command_manager import CommandManager
class Main(unittest.TestCase):
#def testCcs2PcsNeedle(self):
# testfile = join(dirname(__file__), 'filled.conf')
# testcib = join(dirname(__file__), '.testcib.xml')
# testcoro = join(dirname(__file__), '.testcorosync.conf')
# outputs = dict(
# cib=testcib,
# coro=testcoro,
# )
# clufter_args = type("cluster_args", (object, ), dict(
# input=testfile,
# nocheck=True,
# batch=True,
# **outputs)
# )
# for f in outputs.itervalues():
# try:
# unlink(f)
# except OSError:
# pass
# cmd_manager = CommandManager.implicit()
# self.assertFalse(cmd_manager.commands["ccs2pcs-needle"](clufter_args))
# # just the existence of the files is enough for now...
# map(lambda f: self.assertTrue(exists(f)), outputs.itervalues())
def testCcs2PcsNeedleBetter(self):
testfile = join(dirname(__file__), 'filled.conf')
from clufter.formats.simpleconfig import simpleconfig
#from clufter.protocol import protocols
#protocols = protocols.plugins
outputs = {
# alternatives for posterity:
#"cib" : {'passin': protocols['bytestring']},
#"cib" : {'passin': 'bytestring'},
"cib" : {'passin': simpleconfig.BYTESTRING},
"coro": {'passin': simpleconfig.STRUCT},
}
clufter_args = type("cluster_args", (object, ), dict(
input=testfile,
nocheck=True,
batch=True,
**outputs)
)
# alternatively:
#commands = CommandManager.lookup('ccs2pcs-needle')
#cmd_manager = CommandManager(plugins=commands, paths=None)
#cmd = cmd_manager.commands['ccs2pcs-needle']
cmd = CommandManager.init_lookup('ccs2pcs').commands['ccs2pcs-needle']
self.assertFalse(cmd(clufter_args))
# just the existence of non-null strings is enough for now...
map(lambda fspec: self.assertTrue(fspec['passout']), outputs.values())
if __name__ == '__main__':
unittest.main()
|