summaryrefslogtreecommitdiffstats
path: root/tests/pyanaconda_test/indexed_dict_test.py
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2011-05-04 15:58:48 +0200
committerAles Kozumplik <akozumpl@redhat.com>2011-05-19 13:40:34 +0200
commit5f3635b946efabd8289cae3a1f2f1a67ca90b11a (patch)
tree2f399b3617d812e9294f11e5dbeaa2eee7572645 /tests/pyanaconda_test/indexed_dict_test.py
parent5f436dce10feb9e78af5ed79bdd364456c8db605 (diff)
downloadanaconda-5f3635b946efabd8289cae3a1f2f1a67ca90b11a.tar.gz
anaconda-5f3635b946efabd8289cae3a1f2f1a67ca90b11a.tar.xz
anaconda-5f3635b946efabd8289cae3a1f2f1a67ca90b11a.zip
IndexedDict class for storing the installer steps
Diffstat (limited to 'tests/pyanaconda_test/indexed_dict_test.py')
-rw-r--r--tests/pyanaconda_test/indexed_dict_test.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/pyanaconda_test/indexed_dict_test.py b/tests/pyanaconda_test/indexed_dict_test.py
new file mode 100644
index 000000000..c56a9df78
--- /dev/null
+++ b/tests/pyanaconda_test/indexed_dict_test.py
@@ -0,0 +1,39 @@
+import mock
+from pyanaconda.indexed_dict import IndexedDict
+
+class IndexedDictTest(mock.TestCase):
+ def instantiation_test(self):
+ d = IndexedDict()
+ self.assertIsInstance(d, IndexedDict)
+
+ def append_test(self):
+ d = IndexedDict()
+ stored_data = [1, 2, 3]
+ d["some_step"] = stored_data
+ self.assertIs(d["some_step"], stored_data)
+
+ def cant_append_test(self):
+ def assign_int(indexed_dict):
+ indexed_dict[3] = [1, 2, 3]
+ d = IndexedDict()
+ self.assertRaises(TypeError, d.__setitem__, 3, [1, 2, 3])
+
+ def referencing_test(self):
+ d = IndexedDict()
+ d["first"] = 10
+ d["second"] = 20
+ d["third"] = 30
+ self.assertEqual(d[0], 10)
+ self.assertEqual(d[1], 20)
+ self.assertEqual(d[2], 30)
+ self.assertRaises(IndexError, d.__getitem__, 3)
+
+ def index_test(self):
+ d = IndexedDict()
+ d["first"] = 10
+ d["second"] = 20
+ d["third"] = 30
+
+ self.assertEqual(d.index("first"), 0)
+ self.assertEqual(d.index("second"), 1)
+ self.assertEqual(d.index("third"), 2) \ No newline at end of file