예제 #1
0
def test_adduser_with_roles():
    handle(['', u'adduser', u'cdent', u'crunk', u'cow', u'monkey'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert the_user.check_password('crunk')
    assert 'cow' in the_user.list_roles()
    assert 'monkey' in the_user.list_roles()
예제 #2
0
def test_adduser_with_roles():
    handle(['', u'adduser', u'cdent', u'crunk', u'cow', u'monkey'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert the_user.check_password('crunk')
    assert 'cow' in the_user.list_roles()
    assert 'monkey' in the_user.list_roles()
예제 #3
0
def test_ltiddlers(capsys):
    handle(['', u'ltiddlers'])
    results, err = capsys.readouterr()
    assert 'bag1' in results
    assert '\ttiddler1' in results
    handle(['', 'ltiddlers', 'bag1'])
    results, err = capsys.readouterr()
    assert 'bag1' in results
    assert '\ttiddler1' in results
예제 #4
0
def test_bag():
    set_stdin(BAG_STRING)
    handle(['', u'bag', u'bag1'])

    the_bag = Bag('bag1')
    the_bag = store.get(the_bag)

    assert the_bag.name == 'bag1'
    assert the_bag.desc == 'hello'
예제 #5
0
def test_bag():
    set_stdin(BAG_STRING)
    handle(['', u'bag', u'bag1'])

    the_bag = Bag('bag1')
    the_bag = store.get(the_bag)

    assert the_bag.name == 'bag1'
    assert the_bag.desc == 'hello'
예제 #6
0
def test_simple_replace():
    handle(['', 'recipeupdate', '/bags/stuff/tiddlers?select=title:monkey',
        '/bags/faster/tiddlers'])

    recipe = store.get(Recipe('hi'))
    recipelist = recipe.get_recipe()

    assert ['faster', ''] in recipelist
    assert ['stuff', 'select=title:monkey'] not in recipelist
예제 #7
0
def test_ltiddlers(capsys):
    handle(['', u'ltiddlers'])
    results, err = capsys.readouterr()
    assert 'bag1' in results
    assert '\ttiddler1' in results
    handle(['', 'ltiddlers', 'bag1'])
    results, err = capsys.readouterr()
    assert 'bag1' in results
    assert '\ttiddler1' in results
예제 #8
0
def test_recipe():
    set_stdin(RECIPE_STRING)
    handle(['', u'recipe', u'recipe1'])

    the_recipe = Recipe('recipe1')
    the_recipe = store.get(the_recipe)

    assert the_recipe.name == 'recipe1'
    assert u'bag1' in the_recipe.get_recipe()[0]
    assert u'bag2' in the_recipe.get_recipe()[1]
예제 #9
0
def test_recipe():
    set_stdin(RECIPE_STRING)
    handle(['', u'recipe', u'recipe1'])

    the_recipe = Recipe('recipe1')
    the_recipe = store.get(the_recipe)

    assert the_recipe.name == 'recipe1'
    assert u'bag1' in the_recipe.get_recipe()[0]
    assert u'bag2' in the_recipe.get_recipe()[1]
예제 #10
0
def test_tiddler():
    set_stdin(TIDDLER_STRING)
    handle(['', u'tiddler', u'bag1', u'tiddler1'])

    the_tiddler = Tiddler('tiddler1', 'bag1')
    the_tiddler = store.get(the_tiddler)

    assert the_tiddler.title == 'tiddler1'
    assert the_tiddler.bag == u'bag1'
    assert the_tiddler.modifier == 'cdent'
예제 #11
0
def test_tiddler():
    set_stdin(TIDDLER_STRING)
    handle(['', u'tiddler', u'bag1', u'tiddler1'])

    the_tiddler = Tiddler('tiddler1', 'bag1')
    the_tiddler = store.get(the_tiddler)

    assert the_tiddler.title == 'tiddler1'
    assert the_tiddler.bag == u'bag1'
    assert the_tiddler.modifier == 'cdent'
def test_simple_replace():
    handle([
        '', 'recipeupdate', '/bags/stuff/tiddlers?select=title:monkey',
        '/bags/faster/tiddlers'
    ])

    recipe = store.get(Recipe('hi'))
    recipelist = recipe.get_recipe()

    assert ['faster', ''] in recipelist
    assert ['stuff', 'select=title:monkey'] not in recipelist
예제 #13
0
def test_double_replace():
    handle(['', 'recipeupdate', '/bags/faster/tiddlers',
        '/bags/thanks/tiddlers?sort=modified',
        '/bags/collapse/tiddlers'])

    recipe = store.get(Recipe('hi'))
    recipelist = recipe.get_recipe()

    assert ['faster', ''] not in recipelist
    assert ['thanks', 'sort=modified'] in recipelist
    assert ['collapse', ''] in recipelist
def test_double_replace():
    handle([
        '', 'recipeupdate', '/bags/faster/tiddlers',
        '/bags/thanks/tiddlers?sort=modified', '/bags/collapse/tiddlers'
    ])

    recipe = store.get(Recipe('hi'))
    recipelist = recipe.get_recipe()

    assert ['faster', ''] not in recipelist
    assert ['thanks', 'sort=modified'] in recipelist
    assert ['collapse', ''] in recipelist
def test_one_simple_tiddler():
    set_stdin('title,text,modifier,tags,one\r\nfoo,Hello There!,bob,foo bar baz,1\r\n')
    handle(['', u'csvimport', u'bag1'])


    tiddler = Tiddler('foo', 'bag1')
    tiddler = store.get(tiddler)

    assert tiddler.title == 'foo'
    assert tiddler.text == 'Hello There!'
    assert sorted(tiddler.tags) == sorted(['foo', 'bar', 'baz'])
    assert tiddler.fields['one'] == '1'
    store.delete(tiddler)
예제 #16
0
def test_server(capsys):
    import tiddlyweb.web.serve
    def start_cherrypy(config):
        print 'host is %s' % config['server_host']['host']
    tiddlyweb.web.serve.start_cherrypy = start_cherrypy
    handle(['', 'server'])
    results, err = capsys.readouterr()
    assert 'host is our_test_domain' in results

    handle(['', 'server', '192.168.1.1', '8001'])
    results, err = capsys.readouterr()
    assert 'host is 192.168.1.1' in results
    config['server_host']['host'] = 'our_test_domain'
예제 #17
0
def test_server(capsys):
    import tiddlyweb.web.serve

    def start_server(config):
        print('host is %s' % config['server_host']['host'])

    tiddlyweb.web.serve.start_server = start_server
    handle(['', 'server'])
    results, err = capsys.readouterr()
    assert 'host is our_test_domain' in results

    handle(['', 'server', '192.168.1.1', '8001'])
    results, err = capsys.readouterr()
    assert 'host is 192.168.1.1' in results
    config['server_host']['host'] = 'our_test_domain'
def test_two_untitled_tiddlers():
    set_stdin("""alpha,beta,gamma,hotel
one,two,three,four
cat,dog,hamster,mouse""")
    handle(['', u'csvimport', u'bag1'])

    tiddlers = [store.get(tiddler) for tiddler
            in store.list_bag_tiddlers(Bag('bag1'))]

    assert len(tiddlers) == 2
    assert tiddlers[0].text == ''
    assert tiddlers[1].text == ''

    assert 'alpha' in tiddlers[0].fields
    assert 'beta' in tiddlers[1].fields
    
    assert (tiddlers[0].fields['alpha'] == 'one' or
        tiddlers[0].fields['alpha'] == 'cat')
def test_tagdex():
    bag = Bag('snippets')
    STORE.put(bag)

    tiddler = Tiddler('index', 'snippets')
    tiddler.text = 'lipsum'
    tiddler.tags = ['foo', 'bar']
    STORE.put(tiddler)

    response, content = req('GET', '/tags/foo')
    assert response.status == 200

    response, content = req('GET', '/tags/bar')
    assert response.status == 200

    with StreamCapture('stdout') as stream:
        handle(['', 'tags'])

        stream.seek(0)
        tags = stream.read().splitlines()
        assert "foo" in tags
        assert "bar" in tags
예제 #20
0
def test_assetcopy():
    target_dir = os.path.join(TMPDIR, 'static_assets')

    # capture STDERR to avoid confusion
    with StreamCapture('stderr') as stream:
        with raises(SystemExit): # no directory provided
            handle(['', 'assetcopy'])

        handle(['', 'assetcopy', target_dir])

        entries = os.listdir(target_dir)
        assert 'favicon.ico' in entries

        with raises(SystemExit): # directory already exists
            handle(['', 'assetcopy', target_dir])
예제 #21
0
def test_assetcopy(): # XXX: does not belong here
    target_dir = os.path.join(TMPDIR, 'static_assets')
    # capture STDERR to avoid confusion -- XXX: might interefere with reporting - belongs into setup/teardown
    stderr = sys.stderr
    from StringIO import StringIO
    sys.stderr = StringIO()

    with raises(SystemExit): # no directory provided
        handle(['', 'assetcopy'])

    handle(['', 'assetcopy', target_dir])

    entries = os.listdir(target_dir)
    assert 'favicon.ico' in entries

    with raises(SystemExit): # directory already exists
        handle(['', 'assetcopy', target_dir])

    sys.stderr = stderr # restore
예제 #22
0
def test_lusers(capsys):
    handle(['', 'lusers'])
    results, err = capsys.readouterr()
    # cdent user with role monkey was created above
    assert 'cdent' in results
    assert 'monkey' in results
예제 #23
0
def test_lbags(capsys):
    handle(['', u'lbags'])
    results, err = capsys.readouterr()
    assert 'Name: bag1' in results
예제 #24
0
def test_userpass():
    handle(['', u'userpass', u'cdent', u'drunk'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert the_user.check_password('drunk')
예제 #25
0
def test_addrole():
    handle(['', u'addrole', u'cdent', u'pig'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert 'cow' in the_user.list_roles()
예제 #26
0
def test_lrecipes(capsys):
    handle(['', u'lrecipes'])
    results, err = capsys.readouterr()
    assert 'recipe1 ' in results
예제 #27
0
def test_adduser():
    handle(['', u'adduser', u'cdent', u'crunk'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert the_user.check_password('crunk')
예제 #28
0
def test_load_module():
    handle(['twanager', '--load', 'test.test_external_load', 'info'])
    assert global_config['monkey'] == 'bar'
예제 #29
0
def test_lrecipes(capsys):
    handle(['', u'lrecipes'])
    results, err = capsys.readouterr()
    assert 'recipe1 ' in results
예제 #30
0
def test_lbags(capsys):
    handle(['', u'lbags'])
    results, err = capsys.readouterr()
    assert 'Name: bag1' in results
예제 #31
0
def test_lusers(capsys):
    handle(['', 'lusers'])
    results, err = capsys.readouterr()
    # cdent user with role monkey was created above
    assert 'cdent' in results
    assert 'monkey' in results
예제 #32
0
def test_addrole():
    handle(['', u'addrole', u'cdent', u'pig'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert 'cow' in the_user.list_roles()
예제 #33
0
def test_info(capsys):
    handle(['', 'info'])
    results, err = capsys.readouterr()
    assert 'current store is' in results
    assert __version__ in results
예제 #34
0
def test_userpass():
    handle(['', u'userpass', u'cdent', u'drunk'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert the_user.check_password('drunk')
예제 #35
0
def test_info(capsys):
    handle(['', 'info'])
    results, err = capsys.readouterr()
    assert 'current store is' in results
    assert __version__ in results
예제 #36
0
def test_adduser():
    handle(['', u'adduser', u'cdent', u'crunk'])
    the_user = User('cdent')
    the_user = store.get(the_user)
    assert the_user.check_password('crunk')
예제 #37
0
def test_load_module():
    handle(['twanager', '--load', 'test.test_external_load', 'info'])
    assert global_config['monkey'] == 'bar'