Exemplo n.º 1
0
import os
import sys
import unittest
import warnings
from datetime import datetime

from mock import MagicMock, patch, call

from volt.config import Config
from volt.engine.core import Engine, Page, Unit, Pagination, \
        chain_item_permalinks
from volt.exceptions import EmptyUnitsWarning
from volt.test import USER_DIR, make_units_mock, make_uniconfig_mock


UniConfig_mock = make_uniconfig_mock()


class TestEngine(Engine):
    def dispatch(self): pass
    @property
    def units(self):
        if not hasattr(self, '_lazy_units'):
            setattr(self, '_lazy_units', make_units_mock())
        return self._lazy_units
    @units.setter
    def units(self, units): self._lazy_units = units

class TestPage(Page):
    @property
    def id(self): return 'test'
Exemplo n.º 2
0
:license: BSD

"""


import unittest

from mock import patch

from volt.engine.core import Engine
from volt.generator import Site
from volt.plugin.core import Plugin
from volt.test import INSTALL_DIR, make_uniconfig_mock


@patch.object(Site, 'config', make_uniconfig_mock())
class SiteCases(unittest.TestCase):

    def setUp(self):
        self.site = Site()

    @patch('volt.generator.path_import')
    def test_get_processor_unknown_type(self, path_import_mock):
        builtin_engine_name = 'volt.test.fixtures.install_dir.engine.builtins.in_install'
        path_import_mock.return_value = __import__(builtin_engine_name)
        self.assertRaises(AssertionError, self.site.get_processor, \
                'in_install', 'foo', INSTALL_DIR)

    def test_get_processor_unknown_name(self):
        self.assertRaises(ImportError, self.site.get_processor, \
                'foo', 'engines', INSTALL_DIR)