Added testing files Signed-off-by: Imesh Gunaratne <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/cdbb4229 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/cdbb4229 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/cdbb4229 Branch: refs/heads/stratos-4.1.x Commit: cdbb42297520d21d7d2609d698672293cefe8b04 Parents: 73f4003 Author: Milindu Sanoj Kumarage <[email protected]> Authored: Sat Jul 25 12:36:29 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 16:32:46 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/tests/test_print.py | 16 +++++++++++++++ .../python/tests/test_printable_tree_print.py | 21 ++++++++++++++++++++ 2 files changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/cdbb4229/components/org.apache.stratos.python.cli/src/main/python/tests/test_print.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/tests/test_print.py b/components/org.apache.stratos.python.cli/src/main/python/tests/test_print.py new file mode 100644 index 0000000..72a1d70 --- /dev/null +++ b/components/org.apache.stratos.python.cli/src/main/python/tests/test_print.py @@ -0,0 +1,16 @@ +import sys +import unittest +from cli import Utils + + +class MyTestCase(unittest.TestCase): + def test_something(self): + tree = Utils.PrintableTree( + """[{"id":"network-partition-2","partitions":[{"id":"partition-2","partitionMax":0,"property":[{"name":"region","value":"default"}],"public":false},{"id":"partition-3","partitionMax":0,"property":[{"name":"region","value":"default"}],"public":false}]},{"id":"network-partition-1","partitions":[{"id":"partition-1","partitionMax":0,"property":[{"name":"region","value":"default"}],"public":false}]}]""") + tree.print_tree() + output = "hello world!" + self.assertEqual(output, 'hello world!') + + +if __name__ == '__main__': + unittest.main() http://git-wip-us.apache.org/repos/asf/stratos/blob/cdbb4229/components/org.apache.stratos.python.cli/src/main/python/tests/test_printable_tree_print.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/tests/test_printable_tree_print.py b/components/org.apache.stratos.python.cli/src/main/python/tests/test_printable_tree_print.py new file mode 100644 index 0000000..33ef5ce --- /dev/null +++ b/components/org.apache.stratos.python.cli/src/main/python/tests/test_printable_tree_print.py @@ -0,0 +1,21 @@ +import sys +from cli import Utils + + +class TestClass: + + def __init__(self): + pass + + @staticmethod + def test_zero(): + i = 1 + assert i == 1 + + @staticmethod + def test_one(): + tree = Utils.PrintableTree( + """[{"id":"network-partition-2","partitions":[{"id":"partition-2","partitionMax":0,"property":[{"name":"region","value":"default"}],"public":false},{"id":"partition-3","partitionMax":0,"property":[{"name":"region","value":"default"}],"public":false}]},{"id":"network-partition-1","partitions":[{"id":"partition-1","partitionMax":0,"property":[{"name":"region","value":"default"}],"public":false}]}]""") + tree.print_tree() + output = sys.stdout.getline().strip() # because stdout is an StringIO instance + assert output == 'hello world!'
