deb-murano/murano/tests/unit/engine/meta/TestMock.yaml
Ekaterina Chernova 772be690a8 [test-runner] Refactor mock unit-tests
Move asserts from Python to MuranoPL code, so now
test case are fully written in MuranoPL.

Change-Id: I64dc2d1064cae53ca773dcaa3d6dcc606a45c0d2
2016-01-11 12:18:01 +03:00

84 lines
2.3 KiB
YAML

Namespaces:
test: io.murano.test
Name: TestMocks
Extends: test:TestFixture
Properties:
logMessage:
Contract: $.string()
Default: 'Mock from property'
Methods:
initialize:
Body:
- $.originalClass: new(TestMocksFixture)
mock1:
Body:
- Return: 'This is mock1'
testInjectMethodWithString:
Body:
- inject(TestMocksFixture, simpleMethod1, $this, mock1)
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('This is mock1', $output)
testInjectObjectWithString:
Body:
- inject($.originalClass, simpleMethod1, $this, mock1)
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('This is mock1', $output)
testInjectMethodWithYaqlExpr:
Body:
# Calling original method without mocking
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('method1', $output)
- $mockText: 'I am mock'
- inject(TestMocksFixture, simpleMethod1, $mockText)
# Calling original method after mocking
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('I am mock', $output)
testInjectMethodWithYaqlExpr2:
Body:
# Calling original method without mocking
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('method1', $output)
- inject(TestMocksFixture, simpleMethod1, $.logMessage)
# Calling mocked method
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('Mock from property', $output)
testInjectObjectWithYaqlExpr:
Body:
# Calling original method without mocking
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('method1', $output)
- $mockText: 'I am mock'
- inject($.originalClass, simpleMethod1, $mockText)
# Calling original method after mocking
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('I am mock', $output)
testWithoriginal:
Body:
- inject(TestMocksFixture, simpleMethod1, withOriginal(t => $.originalClass.someProperty) -> $t)
- $output: $.originalClass.simpleMethod1()
- $.assertEqual(DEFAULT, $output)
testOriginalMethod:
Body:
- inject(TestMocksFixture, simpleMethod1, originalMethod())
- $output: $.originalClass.simpleMethod1()
- $.assertEqual('method1', $output)