Example #1
0
def test_should_not_match_non_pyembed_link():
    md = Mock()

    re = PyEmbedPattern(None, md).getCompiledRegExp()
    match = re.match('[example](http://www.example.com)')

    assert not match
Example #2
0
def test_should_match_pyembed_link_with_params():
    md = Mock()

    re = PyEmbedPattern(None, md).getCompiledRegExp()
    match = re.match('[!embed?param=value](http://www.example.com)')

    assert match
Example #3
0
def generic_embed_test(source, *embed_params):
    md = Mock()
    pyembed = Mock()
    pyembed.embed.return_value = '<h1>Bees!</h1>'

    pattern = PyEmbedPattern(pyembed, md)
    match = pattern.getCompiledRegExp().match(source)

    result = pattern.handleMatch(match)
    assert result

    pyembed.embed.assert_called_with(*embed_params)
    md.htmlStash.store.assert_called_with('<h1>Bees!</h1>')