Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2359)

Unified Diff: appengine/findit/libs/test/meta_object_test.py

Issue 2641583002: [Cuprit-finder] Add MetaDict class. (Closed)
Patch Set: Update doc. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/libs/test/meta_dict_serializer_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/libs/test/meta_object_test.py
diff --git a/appengine/findit/libs/test/meta_object_test.py b/appengine/findit/libs/test/meta_object_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..b60f6608c4eddfd0e845ae112248f69b3d92444c
--- /dev/null
+++ b/appengine/findit/libs/test/meta_object_test.py
@@ -0,0 +1,45 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+
+from libs.meta_object import Element
+from libs.meta_object import MetaDict
+
+
+class ElementTest(unittest.TestCase):
+ """Tests ``Element`` class."""
+
+ def testIsElement(self):
+ """Tests that the ``IsElement`` of ``Element`` object returns True."""
+ self.assertTrue(Element().is_element)
+
+
+class MetaDictTest(unittest.TestCase):
+ """Tests ``MetaDict`` class."""
+
+ def testIsElement(self):
+ """Tests that the ``IsElement`` of ``MetaDict`` object returns True."""
+ self.assertFalse(MetaDict({}).is_element)
+
+ def testMetaDictGetAndSetItem(self):
+ """Tests "get" and "set" item behavior of ``MetaDict``."""
+ d = {'a': 1, 'b': 2, 'c': 3}
+ meta_dict = MetaDict(d)
+ self.assertEqual(meta_dict['a'], d['a'])
+ self.assertEqual(meta_dict.get('b'), d.get('b'))
+ meta_dict['a'] = 9
+ d['a'] = 9
+ self.assertEqual(meta_dict['a'], d['a'])
+
+ def testMetaDictIterDict(self):
+ """Tests iterating ``MetaDict``."""
+ d = {'a': 1, 'b': 2, 'c': 3}
+ meta_dict = MetaDict(d)
+ self.assertListEqual(list(key for key in meta_dict), list(key for key in d))
+ self.assertListEqual(list(meta_dict.iteritems()), list(d.iteritems()))
+ self.assertListEqual(list(meta_dict.itervalues()), list(d.itervalues()))
+ self.assertListEqual(meta_dict.keys(), d.keys())
+ self.assertListEqual(meta_dict.values(), d.values())
+ self.assertEqual(MetaDict(d), MetaDict(d))
« no previous file with comments | « appengine/findit/libs/test/meta_dict_serializer_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698