summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2014-12-18 12:52:30 -0500
committerKenny Woodson <kwoodson@redhat.com>2014-12-18 13:21:14 -0500
commit2d7624e4f06cb053487059989def7b8b647b57a0 (patch)
treec344c448fbe72531d6ae0ea5dd194ad62375a8f9 /test
parent164094a4adddc767f894b6b42c9ceff0d4bae19e (diff)
downloadopenshift-2d7624e4f06cb053487059989def7b8b647b57a0.tar.gz
openshift-2d7624e4f06cb053487059989def7b8b647b57a0.tar.bz2
openshift-2d7624e4f06cb053487059989def7b8b647b57a0.tar.xz
openshift-2d7624e4f06cb053487059989def7b8b647b57a0.zip
unittest for merge_destructively. More to come
Added a readme so its obvious how to run tests Leaving this alone. Getting cleaned up in next PR Fixing space
Diffstat (limited to 'test')
-rw-r--r--test/env-setup8
-rw-r--r--test/units/README.md7
-rwxr-xr-xtest/units/mutli_ec2_test.py67
3 files changed, 82 insertions, 0 deletions
diff --git a/test/env-setup b/test/env-setup
new file mode 100644
index 000000000..156593571
--- /dev/null
+++ b/test/env-setup
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+CUR_PATH=$(pwd)
+
+PREFIX_PYTHONPATH=$CUR_PATH/inventory/
+
+
+export PYTHONPATH=$PREFIX_PYTHONPATH:$PYTHONPATH
diff --git a/test/units/README.md b/test/units/README.md
new file mode 100644
index 000000000..3bed227eb
--- /dev/null
+++ b/test/units/README.md
@@ -0,0 +1,7 @@
+Location for python unittests.
+
+These should be run by sourcing the env-setup:
+$ source test/env-setup
+
+Then navigate to the test/units/ directory.
+$ python -m unittest multi_ec2_test
diff --git a/test/units/mutli_ec2_test.py b/test/units/mutli_ec2_test.py
new file mode 100755
index 000000000..4e6fe61c5
--- /dev/null
+++ b/test/units/mutli_ec2_test.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+
+import unittest
+import sys
+import os
+import sys
+import multi_ec2
+
+class MultiEc2Test(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def test_merge_simple_1(self):
+ a = {"key1" : 1}
+ b = {"key1" : 2}
+ result = {}
+ [multi_ec2.MultiEc2.merge_destructively(result, x) for x in [a,b]]
+ self.assertEqual(result, {"key1": [1,2]})
+
+ def test_merge_b_empty(self):
+ a = {"key1" : 1}
+ b = {}
+ result = {}
+ [multi_ec2.MultiEc2.merge_destructively(result, x) for x in [a,b]]
+ self.assertEqual(result, {"key1": 1})
+
+ def test_merge_a_empty(self):
+ b = {"key1" : 1}
+ a = {}
+ result = {}
+ [multi_ec2.MultiEc2.merge_destructively(result, x) for x in [a,b]]
+ self.assertEqual(result, {"key1": 1})
+
+ def test_merge_hash_array(self):
+ a = {"key1" : {"hasha": 1}}
+ b = {"key1" : [1,2]}
+ result = {}
+ [multi_ec2.MultiEc2.merge_destructively(result, x) for x in [a,b]]
+ self.assertEqual(result, {"key1": [{"hasha": 1}, 1,2]})
+
+ def test_merge_array_hash(self):
+ a = {"key1" : [1,2]}
+ b = {"key1" : {"hasha": 1}}
+ result = {}
+ [multi_ec2.MultiEc2.merge_destructively(result, x) for x in [a,b]]
+ self.assertEqual(result, {"key1": [1,2, {"hasha": 1}]})
+
+ def test_merge_keys_1(self):
+ a = {"key1" : [1,2], "key2" : {"hasha": 2}}
+ b = {"key2" : {"hashb": 1}}
+ result = {}
+ [multi_ec2.MultiEc2.merge_destructively(result, x) for x in [a,b]]
+ self.assertEqual(result, {"key1": [1,2], "key2": {"hasha": 2, "hashb": 1}})
+
+ def test_merge_recursive_1(self):
+ a = {"a" : {"b": {"c": 1}}}
+ b = {"a" : {"b": {"c": 2}}}
+ result = {}
+ [multi_ec2.MultiEc2.merge_destructively(result, x) for x in [a,b]]
+ self.assertEqual(result, {"a": {"b": {"c": [1,2]}}})
+
+ def tearDown(self):
+ pass
+
+if __name__ == "__main__":
+ unittest.main()