コード例 #1
0
def test_recipe_put():
	_cleanup()

	config = {
		"server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
		"instance_tiddlers": {},
		"root_dir": ""
	}
	env = { "tiddlyweb.config": config }
	store = Storage(config["server_store"][1], env)

	name = "foo"
	recipe = Recipe(name)
	store.recipe_put(recipe)

	assert os.path.exists("%s/%s.recipe" % (STORE_DIR, name))
コード例 #2
0
def test_list_bags():
	_cleanup()

	config = {
		"server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
		"instance_tiddlers": {
			"alpha": ["%s/alpha/index.recipe" % REPO_DIR],
			"bravo": ["%s/bravo/index.recipe" % REPO_DIR]
		},
		"root_dir": ""
	}
	env = { "tiddlyweb.config": config }
	store = Storage(config["server_store"][1], env)

	actual = [bag.name for bag in store.list_bags()]
	expected = ["bravo", "alpha"]
	assert sorted(actual) == sorted(expected)
コード例 #3
0
def test_list_recipes():
    _cleanup()

    config = {
        "server_store": ["tiddlywebplugins.devstore", {"store_root": STORE_DIR}],
        "instance_tiddlers": {},
        "root_dir": "",
    }
    env = {"tiddlyweb.config": config}
    store = Storage(config["server_store"][1], env)

    for name in ["alpha", "bravo", "charlie"]:
        filepath = "%s.recipe" % os.path.join(STORE_DIR, name)
        open(filepath, "w").close()

    actual = [recipe.name for recipe in store.list_recipes()]
    expected = ["bravo", "alpha", "charlie"]
    assert set(actual) == set(expected)
コード例 #4
0
def test_tiddler_put():
	_cleanup()

	config = {
		"server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
		"instance_tiddlers": {
			"myBag": []
		},
		"root_dir": ""
	}
	env = { "tiddlyweb.config": config }
	store = Storage(config["server_store"][1], env)

	tiddler = Tiddler("lorem")
	tiddler.bag = "myBag"
	store.tiddler_put(tiddler)

	tiddler_path = os.path.join(STORE_DIR, tiddler.bag, "%s.tid" % tiddler.title)
	assert os.path.exists(tiddler_path)
コード例 #5
0
def test_bag_get():
    _cleanup()

    config = {
        "server_store": ["tiddlywebplugins.devstore", {"store_root": STORE_DIR}],
        "instance_tiddlers": {"myBag": ["%s/bravo/index.recipe" % REPO_DIR]},
        "root_dir": "",
    }
    env = {"tiddlyweb.config": config}
    store = Storage(config["server_store"][1], env)

    bag = Bag("myBag")
    bag = store.bag_get(bag)

    assert bag.name == "myBag"

    actual = [tiddler.title for tiddler in bag.list_tiddlers()]
    expected = ["lorem", "foo", "SiteTitle", "ipsum", "bar"]
    assert set(actual) == set(expected)  # XXX: sets as temporary workaround for dupes issue
コード例 #6
0
def test_tiddler_get():
	_cleanup()

	config = {
		"server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
		"instance_tiddlers": {
			"myBag": ["%s/alpha/index.recipe" % REPO_DIR]
		},
		"root_dir": ""
	}
	env = { "tiddlyweb.config": config }
	store = Storage(config["server_store"][1], env)

	tiddler = Tiddler("lorem")
	tiddler.bag = "myBag"
	t = store.tiddler_get(tiddler)

	assert t.title == "lorem"
	assert t.bag == "myBag"
	assert t.tags == []
	assert t.creator == "FND"
	assert t.modifier == "FND"
	assert len(t.created) == 14
	assert len(t.modified) == 14
	assert t.created == t.modified
	assert t.text == "lorem ipsum"

	tiddler = Tiddler("foo")
	tiddler.bag = "myBag"
	t = store.tiddler_get(tiddler)

	assert t.title == "foo"
	assert t.bag == "myBag"
	assert t.type == "text/javascript"
	assert t.revision == 1
	assert t.tags == ["systemConfig"]
	assert t.creator == None
	assert t.modifier == None
	assert len(t.created) == 14
	assert len(t.modified) == 14
	assert t.created == t.modified
	assert t.text == 'console.log("foo");'