def test_view_wikiwords_link(): wikklytextplugins.init(config) test_tiddler = Tiddler("Email, Notifications, Atom Feeds and WikklyText") test_tiddler.text = "<<view title linkexternal prefix:/posts/>>" link_context = { '$BASE_URL': '/test', '$REFLOW': 0 } out = macros.view(WikiContext(test_tiddler,{},link_context), WikiArgument("title"),WikiArgument("linkexternal"),WikiArgument("prefix:/posts/")) assert 'a href=' in out assert '/test' not in out assert '/posts/Email%2C%20Notifications%2C%20Atom%20Feeds%20and%20WikklyText' in out
def test_view_link(): config['wikklytext.safe_mode'] = False wikklytextplugins.init(config) link_context = { '$BASE_URL': '/test/bags/foo/tiddlers', '$REFLOW': 0 } out = macros.view(WikiContext(test_tiddler,{},link_context), WikiArgument("title"),WikiArgument("link")) assert 'Test Tiddler' in out assert '</a>' in out assert 'href="/test/bags/foo/tiddlers/Test%20Tiddler"' in out test_tiddler.fields['bar'] = "80 days" test_tiddler.text = "<<view bar linkexternal withlotsargument: 'wondering how this might show' inparams: becauseihavenoidea foo:bar prefix:'around the world in/'>>" text = wikklytextrender.render(test_tiddler,{'tiddlyweb.config':config}) assert 'around the world in/80%20days' in text
def test_view_wikified(): wikklytextplugins.init(config) text ="''testing bold''" test_tiddler.fields['foo'] = 'ok computer' test_tiddler.text = text out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("text"), WikiArgument("wikified")) assert '</b>' in out assert 'testing bold' in out test_tiddler.text = "<<view foo text>>" '''following test needs a working wikklytext/up to date tiddlyweb''' #out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("text"),WikiArgument("wikified")) #assert 'ok computer' in out test_tiddler.text = '[[out]]' out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("text"), WikiArgument("wikified")) assert "</a>" in out
def test_tiddler(): #setup wikklytextplugins.init({}) store.put(Bag("bar")) store.put(Bag("foo")) recipe = Recipe("foo") recipe.set_recipe([['foo', ''], ['bar', '']]) store.put(recipe) tid = Tiddler("jon robson", "bar") tid.text = "My name is Jon Robson" store.put(tid) tid = Tiddler("a tiddler in foo", "foo") tid.text = "rainbow [[title]]" store.put(tid) tid = Tiddler("foo", "bar") tid.tags = ['ab', 'cd', 'ef gh'] #run and verify out = macros.tiddler(WikiContext(tid, config), WikiArgument("jon robson")) assert 'My name is Jon Robson' in out out = macros.tiddler(WikiContext(tid, config), WikiArgument("a tiddler in foo")) assert out == "" #we are viewing from bag bar not foo. tid.recipe = "foo" out = macros.tiddler(WikiContext(tid, config), WikiArgument("a tiddler in foo")) assert "rainbow" in out #we are viewing from recipe now assert "title</a>" in out #teardown store.delete(Bag("foo")) store.delete(Bag("bar")) store.delete(Recipe("foo"))
def test_tiddler(): #setup wikklytextplugins.init({}) store.put(Bag("bar")) store.put(Bag("foo")) recipe = Recipe("foo") recipe.set_recipe([['foo',''],['bar','']]) store.put(recipe) tid = Tiddler("jon robson","bar") tid.text = "My name is Jon Robson" store.put(tid) tid = Tiddler("a tiddler in foo","foo") tid.text = "rainbow [[title]]" store.put(tid) tid = Tiddler("foo","bar") tid.tags = ['ab', 'cd','ef gh'] #run and verify out = macros.tiddler(WikiContext(tid,config),WikiArgument("jon robson")) assert 'My name is Jon Robson' in out out = macros.tiddler(WikiContext(tid,config),WikiArgument("a tiddler in foo")) assert out == "" #we are viewing from bag bar not foo. tid.recipe = "foo" out = macros.tiddler(WikiContext(tid,config),WikiArgument("a tiddler in foo")) assert "rainbow" in out #we are viewing from recipe now assert "title</a>" in out #teardown store.delete(Bag("foo")) store.delete(Bag("bar")) store.delete(Recipe("foo"))