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

Unified Diff: third_party/infra/libs/infra_types/test/infra_types_test.py

Issue 1347263002: Revert of Cross-repo recipe package system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 3 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 | « third_party/infra/libs/infra_types/test/__init__.py ('k') | third_party/recipe_engine/README.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/infra/libs/infra_types/test/infra_types_test.py
diff --git a/third_party/infra/libs/infra_types/test/infra_types_test.py b/third_party/infra/libs/infra_types/test/infra_types_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..77b8f417bd253b0ca590bddb3c1c7125e1e46ed3
--- /dev/null
+++ b/third_party/infra/libs/infra_types/test/infra_types_test.py
@@ -0,0 +1,85 @@
+# Copyright 2015 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
+import collections
+
+from infra.libs import infra_types
+
+
+class TestFreeze(unittest.TestCase):
+ def testDict(self):
+ d = collections.OrderedDict()
+ d['cat'] = 100
+ d['dog'] = 0
+
+ f = infra_types.freeze(d)
+ self.assertEqual(d, f)
+ self.assertIsInstance(f, infra_types.FrozenDict)
+ self.assertEqual(
+ hash(f),
+ hash((0, ('cat', 100))) ^ hash((1, ('dog', 0)))
+ )
+ self.assertEqual(len(d), len(f))
+
+ # Cover equality
+ self.assertEqual(f, f)
+ self.assertNotEqual(f, 'dog')
+ self.assertNotEqual(f, {'bob': 'hat'})
+ self.assertNotEqual(f, {'cat': 20, 'dog': 10})
+
+ def testList(self):
+ l = [1, 2, {'bob': 100}]
+ f = infra_types.freeze(l)
+ self.assertSequenceEqual(l, f)
+ self.assertIsInstance(f, tuple)
+
+ def testSet(self):
+ s = {1, 2, infra_types.freeze({'bob': 100})}
+ f = infra_types.freeze(s)
+ self.assertEqual(s, f)
+ self.assertIsInstance(f, frozenset)
+
+
+class TestThaw(unittest.TestCase):
+ def testDict(self):
+ d = {
+ 'cat': 100,
+ 'dog': 0,
+ }
+ f = infra_types.freeze(d)
+ t = infra_types.thaw(f)
+ self.assertEqual(d, f)
+ self.assertEqual(t, f)
+ self.assertEqual(d, t)
+ self.assertIsInstance(t, collections.OrderedDict)
+
+ def testOrderedDictRetainsOrder(self):
+ d = collections.OrderedDict()
+ d['cat'] = 100
+ d['dog'] = 0
+ f = infra_types.freeze(d)
+ t = infra_types.thaw(f)
+ self.assertEqual(d, f)
+ self.assertEqual(t, f)
+ self.assertEqual(d, t)
+ self.assertIsInstance(t, collections.OrderedDict)
+
+ def testList(self):
+ l = [1, 2, {'bob': 100}]
+ f = infra_types.freeze(l)
+ t = infra_types.thaw(f)
+ self.assertSequenceEqual(l, f)
+ self.assertSequenceEqual(f, t)
+ self.assertSequenceEqual(l, t)
+ self.assertIsInstance(t, list)
+
+ def testSet(self):
+ s = {1, 2, 'cat'}
+ f = infra_types.freeze(s)
+ t = infra_types.thaw(f)
+ self.assertEqual(s, f)
+ self.assertEqual(f, t)
+ self.assertEqual(t, s)
+ self.assertIsInstance(t, set)
« no previous file with comments | « third_party/infra/libs/infra_types/test/__init__.py ('k') | third_party/recipe_engine/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698