Esempio n. 1
0
class SuperTestCase(unittest.TestCase):
    """
    Provides a base for higher level test cases.
    """
    def setUp(self):
        """
        Creates an application and 
        almost launches it.
        """
        logFileName = Path('tmp/app data/test.conf')
        Config._getConfigPathOptions = lambda s: [logFileName]
        if not logFileName.dirname().exists():
            logFileName.dirname().makedirs()
        confParser = ConfigParser()
        self._setupConfigFile(confParser)
        confParser.write(logFileName)
        self.app = Application()
        self.app.loadConfiguration()
        self.app.preLaunch()
        self.client = FakeClient()
        self.package = Package('temp')
        self.app.webServer.root.bindNewPackage(self.package)
        self.mainpage = self.app.webServer.root.children['temp']
    def tearDown(self):
        """
        Remove the global app instance
        """
        from exe import globals
        globals.application = None
    def _setupConfigFile(self, configParser):
        """
        Override this to setup any customised config
        settings
        """
        system = configParser.addSection('system')
        system.exePath = '../exe/exe'
        system.exeDir = '../exe'
        system.webDir = '../exe/webui'
        system.localeDir = '../exe/locale'
        system.port = 8081
        tmpDir = Path('tmp')
        if not tmpDir.exists(): tmpDir.mkdir()
        dataDir = tmpDir/'data'
        if not dataDir.exists():
            dataDir.mkdir()
        system.dataDir = dataDir
        system.browserPath = 'not really used in tests so far'
        logging = configParser.addSection('logging')
        logging.root = 'DEBUG'
    def _request(self, **kwargs):
        """
        Pass me args and I return you a fake request object.
        eg. self._request(action='addIdevice').args['action'][0] == 'addIdevice'
        """
        return FakeRequest(**kwargs)
Esempio n. 2
0
 def setUp(self):
     class MyConfig:
         def __init__(self):
             self.port       = 8081
             self.dataDir    = Path(".")
             self.webDir     = Path(".")
             self.exeDir     = Path(".")
             self.configDir  = Path(".")
             self.styles     = ["default"]
     app = Application()
     app.config = MyConfig()
     app.preLaunch()
     self.client = FakeClient()
     self.package = Package('temp')
     app.webServer.root.bindNewPackage(self.package)
     self.outline = app.webServer.root.children['temp'].outlinePane
Esempio n. 3
0
    def setUp(self):
        """
        Creates an application and
        almost launches it.
        """
        # Make whatever config class that application uses only look for our
        # Set up our customised config file
        logFileName = Path('tmp/app data/test.conf')
        sys.argv[0] = 'exe/exe'
        Config._getConfigPathOptions = lambda s: [logFileName]
        if not logFileName.dirname().exists():
            logFileName.dirname().makedirs()
        confParser = ConfigParser()
        self._setupConfigFile(confParser)
        confParser.write(logFileName)
        # Start up the app and friends
        if G.application is None:
            G.application = Application()

        self.app = G.application
        G.application = self.app
        self.app.loadConfiguration()
        self.app.preLaunch()
        self.client = FakeClient()
        self.package = Package('temp')
        self.session = FakeSession()
        self.app.webServer.root.bindNewPackage(self.package, self.session)
        self.mainpage = self.app.webServer.root.mainpages[
            self.session.uid]['temp']
        self.mainpage.idevicePane.client = self.client
Esempio n. 4
0
    def testExport(self):
        # Delete the output dir
        outdir = TempDirPath()

        G.application = Application()

        G.application.loadConfiguration()
        G.application.preLaunch()

        # Load a package
        package = Package.load('testing/testPackage2.elp')
        # Do the export
        style_dir = G.application.config.stylesDir / package.style

        exporter = WebsiteExport(G.application.config, style_dir, outdir)

        exporter.export(package)
        # Check that it all exists now
        assert outdir.isdir()
        assert (outdir / 'index.html').isfile()
        # Check that the style sheets have been copied
        for filename in style_dir.files():
            assert ((outdir / filename.basename()).exists(),
                    'Style file "%s" not copied' %
                    (outdir / filename.basename()))

        # Check that each node in the package has had a page made
        pagenodes = Set([p.node for p in exporter.pages])
        othernodes = Set(self._getNodes([], package.root))
        assert pagenodes == othernodes

        for page in exporter.pages:
            self._testPage(page, outdir)
Esempio n. 5
0
    def setUp(self):
        class MyConfig:
            def __init__(self):
                self.port = 8081
                self.dataDir = Path(".")
                self.webDir = Path(".")
                self.exeDir = Path(".")
                self.configDir = Path(".")
                self.styles = ["default"]

        app = Application()
        app.config = MyConfig()
        app.preLaunch()
        self.client = FakeClient()
        self.package = Package('temp')
        app.webServer.root.bindNewPackage(self.package)
        self.outline = app.webServer.root.children['temp'].outlinePane
 def setUp(self):
     """
     Creates an application and 
     almost launches it.
     """
     # Make whatever config class that application uses only look for our
     # Set up our customised config file
     logFileName = Path('tmp/app data/test.conf')
     Config._getConfigPathOptions = lambda s: [logFileName]
     if not logFileName.dirname().exists():
         logFileName.dirname().makedirs()
     confParser = ConfigParser()
     self._setupConfigFile(confParser)
     confParser.write(logFileName)
     # Start up the app and friends
     self.app = Application()
     self.app.loadConfiguration()
     self.app.preLaunch()
     self.client = FakeClient()
     self.package = Package('temp')
     self.app.webServer.root.bindNewPackage(self.package)
     self.mainpage = self.app.webServer.root.children['temp']
Esempio n. 7
0
 def setUp(self):
     """
     Creates an application and 
     almost launches it.
     """
     logFileName = Path('tmp/app data/test.conf')
     Config._getConfigPathOptions = lambda s: [logFileName]
     if not logFileName.dirname().exists():
         logFileName.dirname().makedirs()
     confParser = ConfigParser()
     self._setupConfigFile(confParser)
     confParser.write(logFileName)
     self.app = Application()
     self.app.loadConfiguration()
     self.app.preLaunch()
     self.client = FakeClient()
     self.package = Package('temp')
     self.app.webServer.root.bindNewPackage(self.package)
     self.mainpage = self.app.webServer.root.children['temp']
Esempio n. 8
0
    def check_application_for_test(cls):
        logFileName = Path('tmp/app data/test.conf')
        sys.argv[0] = 'exe/exe'
        Config._getConfigPathOptions = lambda s: [logFileName]
        if not logFileName.dirname().exists():
            logFileName.dirname().makedirs()
        confParser = ConfigParser()
        SuperTestCase.update_config_parser(confParser)
        confParser.write(logFileName)

        if G.application is None:
            G.application = Application()

            G.application.loadConfiguration()
            SuperTestCase.update_config_parser(
                G.application.config.configParser)
            G.application.config.loadSettings()

            G.application.preLaunch()
Esempio n. 9
0
 def setUp(self):
     """
     Creates an application and 
     almost launches it.
     """
     # Make whatever config class that application uses only look for our
     # Set up our customised config file
     logFileName = Path('tmp/app data/test.conf')
     Config._getConfigPathOptions = lambda s: [logFileName]
     if not logFileName.dirname().exists():
         logFileName.dirname().makedirs()
     confParser = ConfigParser()
     self._setupConfigFile(confParser)
     confParser.write(logFileName)
     # Start up the app and friends
     self.app = Application()
     self.app.loadConfiguration()
     self.app.preLaunch()
     self.client = FakeClient()
     self.package = Package('temp')
     self.app.webServer.root.bindNewPackage(self.package)
     self.mainpage = self.app.webServer.root.children['temp']
    group.add_option("--single-page",
                     action="store_true",
                     dest="single",
                     help=_(u"Include Single Page export file").encode(sys.stdout.encoding),
                     default=False)
    group.add_option("--website",
                     action="store_true",
                     dest="website",
                     help=_(u"Include Web Site export files").encode(sys.stdout.encoding),
                     default=False)
    parser.add_option_group(group)

    return parser

if __name__ == "__main__":
    application = Application()
    
    if '--standalone' in sys.argv:
        application.standalone = True
        sys.argv.remove("--standalone")
        
    application.loadConfiguration()
    application.preLaunch()
    optparse._ = application.config.locales[application.config.locale].gettext

    parser = prepareParser()
    options, args = parser.parse_args()
    

    if options.x and options.i:
        parser.error(_(u'Options --export and --import are mutually \
Esempio n. 11
0
        exeDir = os.path.dirname(exePath)
        pythonPath = os.path.split(exeDir)[0]
        sys.path.insert(0, pythonPath)
        from exe.application import Application
    else:
        import traceback
        traceback.print_exc()
        sys.exit(1)

from exe.engine.package  import Package
from exe.engine.path     import Path
from exe.engine.template import Template

if __name__ == "__main__":
    # Load eXe configuration
    application = Application()
    application.processArgs()
    application.loadConfiguration()

    # We have to make sure eXe has english configured as its language to prevent it
    # from pre-translating the templates
    application.config.locale = 'en'
    application.config.loadLocales()

    # The locale path must always be the last parameter
    locale_path = Path(sys.argv[-1])

    try:
        # Try to get templates' strings
        execfile(application.config.templatesDir / 'strings.py')
def main():
    application = Application()
    application.main()
Esempio n. 13
0
                datadict = {
                    'data': attrs_dict[attr_name],
                    'fulldata': self._HTMLParser__starttag_text,
                    'line': self.lineno,
                    'offset': self.offset,
                    'tag': tag,
                    'attr': attr_name,
                    'type': 'tag'
                }

                self.HTMLDATA.append(datadict)


if __name__ == "__main__":
    # Load eXe configuration
    application = Application()
    application.processArgs()
    application.loadConfiguration()

    # We have to make sure eXe has english configured as its language to prevent it
    # from pre-translating the templates
    application.config.locale = 'en'
    application.config.loadLocales()

    # List of strings that shouldn't make it to the .po files
    excluded_strings = [u'', u'.', u'...', u'\n']

    # Open output file and write generation date
    file_w = open(application.config.templatesDir / u'strings.py', 'w')
    file_w.write(u'# Generated on %s\n' % str(datetime.now()))
class SuperTestCase(unittest.TestCase):
    """
    Provides a base for higher level test cases.
    """
    def setUp(self):
        """
        Creates an application and 
        almost launches it.
        """
        # Make whatever config class that application uses only look for our
        # Set up our customised config file
        logFileName = Path('tmp/app data/test.conf')
        Config._getConfigPathOptions = lambda s: [logFileName]
        if not logFileName.dirname().exists():
            logFileName.dirname().makedirs()
        confParser = ConfigParser()
        self._setupConfigFile(confParser)
        confParser.write(logFileName)
        # Start up the app and friends
        self.app = Application()
        self.app.loadConfiguration()
        self.app.preLaunch()
        self.client = FakeClient()
        self.package = Package('temp')
        self.app.webServer.root.bindNewPackage(self.package)
        self.mainpage = self.app.webServer.root.children['temp']

    def tearDown(self):
        """
        Remove the global app instance
        """
        from exe import globals
        globals.application = None

    def _setupConfigFile(self, configParser):
        """
        Override this to setup any customised config
        settings
        """
        # Set up the system section
        system = configParser.addSection('system')
        system.exePath = '../exe/exe'
        system.exeDir = '../exe'
        system.webDir = '../exe/webui'
        system.localeDir = '../exe/locale'
        system.port = 8081
        # Make a temporary dir where we can save packages and exports etc
        tmpDir = Path('tmp')
        if not tmpDir.exists(): tmpDir.mkdir()
        dataDir = tmpDir / 'data'
        if not dataDir.exists():
            dataDir.mkdir()
        system.dataDir = dataDir
        system.browserPath = 'not really used in tests so far'
        # Setup the logging section
        logging = configParser.addSection('logging')
        logging.root = 'DEBUG'

    def _request(self, **kwargs):
        """
        Pass me args and I return you a fake request object.
        eg. self._request(action='addIdevice').args['action'][0] == 'addIdevice'
        """
        return FakeRequest(**kwargs)