Change in vdsm[master]: testlib: Rename __recording__ to __calls__

nsoffer at redhat.com nsoffer at redhat.com
Sun Dec 6 22:16:21 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: testlib: Rename __recording__ to __calls__
......................................................................

testlib: Rename __recording__ to __calls__

This is more correct and more readable. Instance method calls are
recorded in obj.__calls__, and class method calls in
obj.__class_calls__.

Change-Id: I334b01fb66f4460c5f1ee34b65c25057d6ed27d6
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/sdm_indirection_tests.py
M tests/testlib.py
M tests/testlibTests.py
M tests/vmTests.py
4 files changed, 28 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/49962/1

diff --git a/tests/sdm_indirection_tests.py b/tests/sdm_indirection_tests.py
index 764be11..0362db2 100644
--- a/tests/sdm_indirection_tests.py
+++ b/tests/sdm_indirection_tests.py
@@ -32,7 +32,7 @@
         self.domaindir = '/a/b/c'
         self.mountpoint = '/a/b'
         self._metadata = {}
-        self.__class__.__class_recording__ = []
+        self.__class__.__class_calls__ = []
 
     @recorded
     def replaceMetadata(self, md):
@@ -291,7 +291,7 @@
         self._imagePath = '/a/b'
         self._volumePath = '/a/b/c'
         self.voltype = None
-        self.__class__.__class_recording__ = []
+        self.__class__.__class_calls__ = []
 
     @classmethod
     @recorded
@@ -424,7 +424,7 @@
     def check_method(self, fn, args, result):
         target = getattr(self.source_instance, self.target_name)
         getattr(self.source_instance, fn)(*args)
-        self.assertEqual(result, target.__recording__)
+        self.assertEqual(result, target.__calls__)
 
     def check_method_call(self, fn, nr_args=0):
         args = tuple(range(nr_args))
@@ -434,7 +434,7 @@
         args = tuple(range(nr_args))
         target = getattr(self.source_instance, self.target_name)
         getattr(self.source_instance, fn)(*args)
-        self.assertEqual([(fn, args, {})], target.__class_recording__)
+        self.assertEqual([(fn, args, {})], target.__class_calls__)
 
     def assertEqual(self, expected, actual):
         assert actual == expected, "expected: %r got: %r" % (expected, actual)
@@ -525,7 +525,7 @@
     def test_acquirevolumemetadataslot(self):
         with self.domain.acquireVolumeMetadataSlot(0, 1):
             result = [('acquireVolumeMetadataSlot', (0, 1), {})]
-            self.assertEqual(self.domain._manifest.__recording__, result)
+            self.assertEqual(self.domain._manifest.__calls__, result)
 
     @permutations([
         ['extend', 2],
diff --git a/tests/testlib.py b/tests/testlib.py
index 7d98cb4..7f028a4 100644
--- a/tests/testlib.py
+++ b/tests/testlib.py
@@ -413,13 +413,13 @@
 
 def recorded(meth):
     """
-    Method decorator recording calls to receiver __recording__ list.
+    Method decorator recording calls to receiver __calls__ list.
 
     Can decorate an instance method or class method. Instance methods are
-    stored in the instance __recording__ list, and class methods in the class
-    __class_recording__ list.
+    stored in the instance __calls__ list, and class methods in the class
+    __class_calls__ list.
 
-    You are responsible for clearing the class __class_recording__.
+    You are responsible for clearing the class __class_calls__.
 
     Note: when decorating a class method, this decorator must be after the
     @classmethod decorator:
@@ -435,9 +435,9 @@
     @wraps(meth)
     def wrapper(obj, *args, **kwargs):
         if inspect.isclass(obj):
-            name = "__class_recording__"
+            name = "__class_calls__"
         else:
-            name = "__recording__"
+            name = "__calls__"
         try:
             recording = getattr(obj, name)
         except AttributeError:
diff --git a/tests/testlibTests.py b/tests/testlibTests.py
index 9e721fa..4678368 100644
--- a/tests/testlibTests.py
+++ b/tests/testlibTests.py
@@ -66,72 +66,72 @@
 
     def setUp(self):
         try:
-            del Recorded.__class_recording__
+            del Recorded.__class_calls__
         except AttributeError:
             pass
 
     def test_no_args(self):
         obj = Recorded()
         obj.no_args()
-        self.assertEqual(obj.__recording__, [("no_args", (), {})])
+        self.assertEqual(obj.__calls__, [("no_args", (), {})])
 
     def test_args(self):
         obj = Recorded()
         obj.args(1, 2)
-        self.assertEqual(obj.__recording__, [("args", (1, 2), {})])
+        self.assertEqual(obj.__calls__, [("args", (1, 2), {})])
 
     def test_kwargs(self):
         obj = Recorded()
         obj.kwargs(a=1, b=2)
-        self.assertEqual(obj.__recording__, [("kwargs", (), {"a": 1, "b": 2})])
+        self.assertEqual(obj.__calls__, [("kwargs", (), {"a": 1, "b": 2})])
 
     def test_kwargs_as_args(self):
         obj = Recorded()
         obj.kwargs(1, 2)
-        self.assertEqual(obj.__recording__, [("kwargs", (1, 2), {})])
+        self.assertEqual(obj.__calls__, [("kwargs", (1, 2), {})])
 
     def test_no_kwargs(self):
         obj = Recorded()
         obj.args_and_kwargs(1, 2)
-        self.assertEqual(obj.__recording__, [("args_and_kwargs", (1, 2), {})])
+        self.assertEqual(obj.__calls__, [("args_and_kwargs", (1, 2), {})])
 
     def test_some_kwargs(self):
         obj = Recorded()
         obj.args_and_kwargs(1, 2, c=3)
-        self.assertEqual(obj.__recording__,
+        self.assertEqual(obj.__calls__,
                          [("args_and_kwargs", (1, 2), {"c": 3})])
 
     def test_args_as_kwargs(self):
         obj = Recorded()
         obj.args_and_kwargs(a=1, b=2)
-        self.assertEqual(obj.__recording__,
+        self.assertEqual(obj.__calls__,
                          [("args_and_kwargs", (), {"a": 1, "b": 2})])
 
     def test_flow(self):
         obj = Recorded()
         obj.no_args()
         obj.kwargs(a=1)
-        self.assertEqual(obj.__recording__, [
+        self.assertEqual(obj.__calls__, [
             ("no_args", (), {}),
             ("kwargs", (), {"a": 1}),
         ])
 
     def test_class_method_via_class(self):
         Recorded.class_method('a', b=2)
-        self.assertEqual(Recorded.__class_recording__,
+        self.assertEqual(Recorded.__class_calls__,
                          [('class_method', ('a',), {'b': 2})])
 
     def test_class_method_via_obj(self):
         obj = Recorded()
         obj.class_method('a', b=2)
-        self.assertEqual(Recorded.__class_recording__,
+        self.assertEqual(Recorded.__class_calls__,
                          [('class_method', ('a',), {'b': 2})])
 
     def test_class_method_flow(self):
         obj = Recorded()
         obj.class_method('a', b=2)
         obj.class_method_noargs()
-        self.assertEqual(Recorded.__class_recording__, [
+        self.assertEqual(Recorded.__class_calls__, [
             ('class_method', ('a',), {'b': 2}),
             ('class_method_noargs', (), {}),
         ])
@@ -140,10 +140,10 @@
         obj = Recorded()
         obj.class_method('a', b=2)
         obj.args(1, 2)
-        self.assertEqual(Recorded.__class_recording__, [
+        self.assertEqual(Recorded.__class_calls__, [
             ('class_method', ('a',), {'b': 2}),
         ])
-        self.assertEqual(obj.__recording__, [
+        self.assertEqual(obj.__calls__, [
             ('args', (1, 2), {}),
         ])
 
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 3ec8a1b..7630038 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -1400,7 +1400,7 @@
             target = 256
             res = testvm.setBalloonTarget(target)  # just to fit in 80 cols
             self.assertEqual(res['status']['code'], 0)
-            self.assertEqual(testvm._dom.__recording__,
+            self.assertEqual(testvm._dom.__calls__,
                              [('setMemory', (target,), {})])
 
     def testVmWithoutDom(self):
@@ -1481,12 +1481,12 @@
     def test_freeze(self):
         res = self.vm.freeze()
         self.assertEqual(res, response.success())
-        self.assertEqual(self.dom.__recording__, [("fsFreeze", (), {})])
+        self.assertEqual(self.dom.__calls__, [("fsFreeze", (), {})])
 
     def test_thaw(self):
         res = self.vm.thaw()
         self.assertEqual(res, response.success())
-        self.assertEqual(self.dom.__recording__, [("fsThaw", (), {})])
+        self.assertEqual(self.dom.__calls__, [("fsThaw", (), {})])
 
 
 class FreezingGuestAgentUnresponsiveTests(TestCaseBase):


-- 
To view, visit https://gerrit.ovirt.org/49962
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I334b01fb66f4460c5f1ee34b65c25057d6ed27d6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list