Example #1
0
def test_api_loads(patch):
    """
    Ensures Api.loads can compile a story from a string
    """
    patch.init(Story)
    patch.object(Story, 'process')
    result = Api.loads('string').result()
    Story.__init__.assert_called_with('string')
    Story.process.assert_called_with()
    assert result == Story.process()
Example #2
0
def test_api_loads(patch):
    """
    Ensures Api.loads can compile a story from a string
    """
    patch.init(Story)
    patch.init(Features)
    patch.object(Story, 'process')
    result = Api.loads('string').result()
    Story.__init__.assert_called_with('string', ANY)
    assert isinstance(Story.__init__.call_args[0][1], Features)
    Story.process.assert_called_with()
    assert result == Story.process()
Example #3
0
def test_api_loads(patch, magic):
    """
    Ensures Api.loads can compile a story from a string
    """
    patch.init(Story)
    patch.init(Features)
    patch.object(Story, "process")
    Story.context = magic()
    result = Api.loads("string").result()
    Story.__init__.assert_called_with(
        "string", ANY, scope=None, backend="json", hub=None,
    )
    assert isinstance(Story.__init__.call_args[0][1], Features)
    Story.process.assert_called_with()
    assert result == Story.process()
Example #4
0
def test_api_loads_custom(patch):
    """
    Ensures Api.loads can compile a story from a string
    with a custom backend and scope.
    """
    patch.init(Story)
    patch.init(Features)
    patch.object(Story, "process")
    result = Api.loads(
        "string", backend="custom", scope="my.scope", hub="my.hub"
    ).result()
    Story.__init__.assert_called_with(
        "string", ANY, scope="my.scope", backend="custom", hub="my.hub",
    )
    assert isinstance(Story.__init__.call_args[0][1], Features)
    Story.process.assert_called_with()
    assert result == Story.process()