[mocking-machinery] Add original method function

This commit adds opportunity to call original method
in mock method. Corresponding test is attached.

Targets blueprint mocking-machinery

Change-Id: I889bb576e708d28a083c0a25f66c999a6492057f
This commit is contained in:
Ekaterina Chernova 2015-12-14 15:28:28 +03:00
parent 5aeba4447a
commit b9b2a9b881
2 changed files with 6 additions and 0 deletions

View File

@ -145,6 +145,8 @@ def inject_method_with_yaql_expr(context, target, target_method, expr):
def payload_adapter(__super, __context, __sender, *args, **kwargs):
new_context = context.create_child_context()
new_context[constants.CTX_ORIGINAL_CONTEXT] = __context
new_context.register_function(lambda: __super(*args, **kwargs),
name='originalMethod')
return expr(new_context, __sender, *args, **kwargs)
result_fd.payload = payload_adapter

View File

@ -127,3 +127,7 @@ class TestMockYaqlFunctions(test_case.DslTestCase):
def test_with_original(self):
self.runner.testWithoriginal()
self.assertEqual(['DEFAULT'], self.traces)
def test_original_method(self):
self.runner.testOriginalMethod()
self.assertEqual(['method1'], self.traces)