def test_move(self): cache = cli.ContentCache(join(module_root, 'templates')) cache.set('content/pie.md', 'delicious') cache.move('content/pie.md', 'content/cake.md') assert cache.get('content/pie.md') is None assert cache.get('content/cake.md') == 'delicious' # Doesn't exist; no-op cache.move('nope', 'yep') assert cache.get('yep') is None
def test_read(self): cache = cli.ContentCache(join(module_root, 'templates')) # Read from content helloworld = codecs.open(join(module_root, 'templates', 'content', 'articles', 'hello-world.md'), encoding='utf-8').read() assert cache.read('content/articles/hello-world.md') == helloworld assert cache.get('content/articles/hello-world.md') == helloworld cache.set('content/articles/hello-world.md', 'b') assert cache.get('content/articles/hello-world.md') == 'b' # Read from layouts basic = open(join(module_root, 'templates', 'layouts', 'basic.html')).read() assert cache.read('layouts/basic.html') == basic # Read missing file assert cache.read('layouts/nope.html') is None
def test_warm(self): cache = cli.ContentCache(join(module_root, 'templates')) cache.warm() basic = open(join(module_root, 'templates', 'layouts', 'basic.html')).read() assert cache.get('layouts/basic.html') == basic
def test_delete(self): cache = cli.ContentCache(join(module_root, 'templates')) cache.set('content/pie.md', 'delicious') assert cache.get('content/pie.md') == 'delicious' cache.delete('content/pie.md') assert cache.get('content/pie.md') is None
def test_missing(self): cache = cli.ContentCache(join(module_root, 'templates')) assert cache.get('nope') is None