Example #1
0
from hyde._compat import PY3
from hyde.ext.templates.jinja import Jinja2Template
from hyde.site import Site
from hyde.generator import Generator
from hyde.model import Config

from fswrap import File
from jinja2.utils import generate_lorem_ipsum
from nose.plugins.skip import SkipTest
from nose.tools import nottest
from pyquery import PyQuery

import yaml

ROOT = File(__file__).parent
JINJA2 = ROOT.child_folder('templates/jinja2')


class Article(object):

    def __init__(self, id):
        self.id = id
        self.href = '/article/%d' % self.id
        self.title = generate_lorem_ipsum(1, False, 5, 10)
        self.user = choice(users)
        self.body = generate_lorem_ipsum()
        self.pub_date = datetime.utcfromtimestamp(
            randrange(10 ** 9, 2 * 10 ** 9))
        self.published = True

Example #2
0
# -*- coding: utf-8 -*-
"""
Use nose
`$ pip install nose`
`$ nosetests`
"""
import os

from hyde._compat import str
from hyde.layout import Layout, HYDE_DATA, LAYOUTS

from fswrap import File
from nose.tools import nottest, with_setup

DATA_ROOT = File(__file__).parent.child_folder('data')
LAYOUT_ROOT = DATA_ROOT.child_folder(LAYOUTS)


@nottest
def setup_data():
    DATA_ROOT.make()


@nottest
def cleanup_data():
    DATA_ROOT.delete()


def test_find_layout_from_package_dir():
    f = Layout.find_layout()
    assert f.name == 'basic'
Example #3
0
def test_child_folder():
    p = File(__file__).parent
    c = p.child_folder("data")
    assert hasattr(c, "child_folder")
    assert unicode(c) == os.path.join(os.path.dirname(__file__), "data")
Example #4
0
def test_fully_expanded_path():
    f = File(__file__).parent
    n = f.child_folder("../" + f.name)
    e = Folder(n.fully_expanded_path)
    assert n != e
    assert f == e
Example #5
0
# -*- coding: utf-8 -*-
"""
Use nose
`$ pip install nose`
`$ nosetests`
"""
from fswrap import File
from gitbot import stack

from nose.tools import nottest
import urllib2
import yaml


TEST_ROOT = File(__file__).parent
MULTI_ROOT = TEST_ROOT.child_folder('multi')
SOURCE_ROOT = MULTI_ROOT.child_folder('source')
SCRIPT_ROOT = MULTI_ROOT.child_folder('scripts')
TEMP = MULTI_ROOT.child_folder('tmp')

conf_path = MULTI_ROOT.child('gitbot.yaml')
settings = yaml.load(File(conf_path).read_all())
settings['file_path'] = conf_path


def teardown():
    TEMP.delete()


def test_validate():
    stack.validate_stack(settings)
Example #6
0
    assert not abc.exists
    abc.delete()
    assert True  # No Exception
    c.delete()


def test_file_or_folder():
    f = FS.file_or_folder(__file__)
    assert isinstance(f, File)
    f = FS.file_or_folder(File(__file__).parent)
    assert isinstance(f, Folder)


DATA_ROOT = File(__file__).parent.child_folder("data")
ROOT_FOLDER = File(__file__).parent.child_folder("arootfolder")
AFOLDER = ROOT_FOLDER.child_folder("afolder")
HELPERS = File(AFOLDER.child("helpers.html"))
INDEX = File(AFOLDER.child("index.html"))
LAYOUT = File(AFOLDER.child("layout.html"))
LOGO = File(ROOT_FOLDER.child("../logo.png"))
XML = File(ROOT_FOLDER.child("../atextfile.xml"))


def test_ancestors():
    depth = 0
    next = AFOLDER
    for folder in INDEX.ancestors():
        assert folder == next
        depth += 1
        next = folder.parent
    assert depth == len(AFOLDER.path.split(os.sep))
Example #7
0
    abc.delete()
    assert not abc.exists
    abc.delete()
    assert True  # No Exception
    c.delete()


def test_file_or_folder():
    f = FS.file_or_folder(__file__)
    assert isinstance(f, File)
    f = FS.file_or_folder(File(__file__).parent)
    assert isinstance(f, Folder)

DATA_ROOT = File(__file__).parent.child_folder('data')
ROOT_FOLDER = File(__file__).parent.child_folder('arootfolder')
AFOLDER = ROOT_FOLDER.child_folder('afolder')
HELPERS = File(AFOLDER.child('helpers.html'))
INDEX = File(AFOLDER.child('index.html'))
LAYOUT = File(AFOLDER.child('layout.html'))
LOGO = File(ROOT_FOLDER.child('../logo.png'))
XML = File(ROOT_FOLDER.child('../atextfile.xml'))


def test_ancestors():
    depth = 0
    next = AFOLDER
    for folder in INDEX.ancestors():
        assert folder == next
        depth += 1
        next = folder.parent
    assert depth == len(AFOLDER.path.split(os.sep))
Example #8
0
def test_child_folder():
    p = File(__file__).parent
    c = p.child_folder('data')
    assert hasattr(c, 'child_folder')
    assert unicode(c) == os.path.join(os.path.dirname(__file__), 'data')
Example #9
0
from hyde._compat import PY3
from hyde.ext.templates.jinja import Jinja2Template
from hyde.site import Site
from hyde.generator import Generator
from hyde.model import Config

from fswrap import File
from jinja2.utils import generate_lorem_ipsum
from nose.plugins.skip import SkipTest
from nose.tools import nottest, eq_
from pyquery import PyQuery

import yaml

ROOT = File(__file__).parent
JINJA2 = ROOT.child_folder('templates/jinja2')


class Article(object):
    def __init__(self, id):
        self.id = id
        self.href = '/article/%d' % self.id
        self.title = generate_lorem_ipsum(1, False, 5, 10)
        self.user = choice(users)
        self.body = generate_lorem_ipsum()
        self.pub_date = datetime.utcfromtimestamp(randrange(10**9, 2 * 10**9))
        self.published = True


def dateformat(x):
    return x.strftime('%Y-%m-%d')
Example #10
0
"""
Use nose
`$ pip install nose`
`$ nosetests`
"""
from fswrap import File
from gitbot import stack
from gitbot.lib.s3 import Bucket
from nose import with_setup
import urllib2
from util import assert_text_equals
import yaml


TEST_ROOT = File(__file__).parent
BEES_ROOT = TEST_ROOT.child_folder('bees')
SOURCE_ROOT = BEES_ROOT.child_folder('source')
SCRIPT_ROOT = BEES_ROOT.child_folder('scripts')
TEMP = BEES_ROOT.child_folder('tmp')


def teardown():
    TEMP.delete()


def delete_bucket():
    conf_path = BEES_ROOT.child('project.yaml')
    config = yaml.load(File(conf_path).read_all())
    config['file_path'] = conf_path
    bucket_name = config['publish']['bucket']
    bucket = Bucket(bucket_name)
Example #11
0
# -*- coding: utf-8 -*-
"""
Use nose
`$ pip install nose`
`$ nosetests`
"""

from gitbot.lib.build import Project
from fswrap import File, Folder
import yaml

HERE = File(__file__).parent
CONF = HERE.child_folder('build_data')

BUILD = yaml.load(CONF.child_file('build.yaml').read_all())


class TestProj1(Project):

    @property
    def subdomain(self):
        return self.config.domain


class TestProj2or3(Project):

    @property
    def subdomain(self):
        return self.config.prefix + '.' + self.config.domain

Example #12
0
# -*- coding: utf-8 -*-
"""
Use nose
`$ pip install nose`
`$ nosetests`
"""
from fswrap import File
from util import assert_text_equals, assert_json_equals

from gitbot import generator

import yaml


TEST_ROOT = File(__file__).parent
BEES_ROOT = TEST_ROOT.child_folder("bees")
SOURCE_ROOT = BEES_ROOT.child_folder("source")
SCRIPT_ROOT = BEES_ROOT.child_folder("scripts")
TEMP = BEES_ROOT.child_folder("tmp")


def teardown():
    TEMP.delete()


def test_bees_template():
    expected = File(BEES_ROOT.child("expected/bees_with_guns.json")).read_all()
    actual = generator.render("cfn.template", search_paths=[SOURCE_ROOT.path, SCRIPT_ROOT.path])
    assert_text_equals(actual, expected)

Example #13
0
# -*- coding: utf-8 -*-
"""
Use nose
`$ pip install nose`
`$ nosetests`
"""
import os

from hyde._compat import str
from hyde.layout import Layout, HYDE_DATA, LAYOUTS

from fswrap import File
from nose.tools import nottest, with_setup

DATA_ROOT = File(__file__).parent.child_folder("data")
LAYOUT_ROOT = DATA_ROOT.child_folder(LAYOUTS)


@nottest
def setup_data():
    DATA_ROOT.make()


@nottest
def cleanup_data():
    DATA_ROOT.delete()


def test_find_layout_from_package_dir():
    f = Layout.find_layout()
    assert f.name == "basic"