Ejemplo n.º 1
0
        from imapfw.testing.edmp import TestEDMP
        from imapfw.testing.types import TestTypeAccount, TestTypeRepository
        from imapfw.testing.architect import TestArchitect, TestDriverArchitect
        from imapfw.testing.architect import TestDriversArchitect
        from imapfw.testing.architect import TestEngineArchitect

        self._suite.addTest(unittest.makeSuite(TestConcurrency))
        self._suite.addTest(unittest.makeSuite(TestRascal))
        self._suite.addTest(unittest.makeSuite(TestFolder))
        self._suite.addTest(unittest.makeSuite(TestMessage))
        self._suite.addTest(unittest.makeSuite(TestMessages))
        self._suite.addTest(unittest.makeSuite(TestMaildirDriver))
        self._suite.addTest(unittest.makeSuite(TestEDMP))
        self._suite.addTest(unittest.makeSuite(TestTypeAccount))
        self._suite.addTest(unittest.makeSuite(TestTypeRepository))
        self._suite.addTest(unittest.makeSuite(TestArchitect))
        self._suite.addTest(unittest.makeSuite(TestDriverArchitect))
        self._suite.addTest(unittest.makeSuite(TestDriversArchitect))
        self._suite.addTest(unittest.makeSuite(TestEngineArchitect))

    def run(self) -> None:
        import unittest

        runner = unittest.TextTestRunner(verbosity=2)
        testResult = runner.run(self._suite)
        if testResult.wasSuccessful():
            self._exitCode = len(testResult.failures)


Parser.addAction('unitTests', UnitTests, help="run the integrated unit tests")
Ejemplo n.º 2
0
from imapfw.conf import Parser

from .interface import ActionInterface

# Annotations.
from imapfw.annotation import ExceptionClass


@checkInterfaces()
@implements(ActionInterface)
class Noop(object):
    """The noop action allows testing the loading of the rascal."""

    honorHooks = False
    requireRascal = False

    def exception(self, e: ExceptionClass) -> None:
        raise NotImplementedError

    def getExitCode(self) -> int:
        return 0

    def init(self, parser: Parser) -> None:
        pass

    def run(self) -> None:
        pass


Parser.addAction('noop', Noop, help="test if the rascal can be loaded")
Ejemplo n.º 3
0
    def _setExitCode(self, exitCode):
        if exitCode > self._exitCode:
            self._exitCode = exitCode

    def exception(self, e: ExceptionClass) -> None:
        self.exitCode = 3
        raise NotImplementedError #TODO

    def getExitCode(self) -> int:
        return self._exitCode

    def init(self, parser: Parser) -> None:
        self._shellName = parser.get('shell_name')

    def run(self) -> None:
        cls_shell = runtime.rascal.get(self._shellName, [Shell])
        shell = cls_shell()
        shell.beforeSession()
        shell.configureCompletion()
        shell.session()
        exitCode = shell.afterSession()
        self._setExitCode(exitCode)

actionParser = Parser.addAction('shell', ShellAction, help="run in shell mode")

actionParser.add_argument(dest="shell_name",
    default=None,
    metavar="SHELL_NAME",
    help="the shell from the rascal to run")
Ejemplo n.º 4
0
 def init(self, parser: Parser) -> None:
     self._shellName = parser.get('shell_name')
Ejemplo n.º 5
0
    def _setExitCode(self, exitCode):
        if exitCode > self._exitCode:
            self._exitCode = exitCode

    def exception(self, e: ExceptionClass) -> None:
        self.exitCode = 3
        raise NotImplementedError  #TODO

    def getExitCode(self) -> int:
        return self._exitCode

    def init(self, parser: Parser) -> None:
        self._shellName = parser.get('shell_name')

    def run(self) -> None:
        cls_shell = runtime.rascal.get(self._shellName, [Shell])
        shell = cls_shell()
        shell.beforeSession()
        shell.configureCompletion()
        shell.session()
        exitCode = shell.afterSession()
        self._setExitCode(exitCode)


actionParser = Parser.addAction('shell', ShellAction, help="run in shell mode")

actionParser.add_argument(dest="shell_name",
                          default=None,
                          metavar="SHELL_NAME",
                          help="the shell from the rascal to run")
Ejemplo n.º 6
0
 def init(self, parser: Parser) -> None:
     self._shellName = parser.get('shell_name')
Ejemplo n.º 7
0
            account = loadAccount(cls_account)
            repositories.append(account.fw_getLeft())
            repositories.append(account.fw_getRight())

        report = Report()
        for repository in repositories:
            if isinstance(repository, DriverInterface):
                continue
            try:
                repository.fw_insertController(ExamineController,
                                               {'report': report})
                driver = repository.fw_getDriver()

                report.title(
                    "Repository %s (driver %s)" %
                    (repository.getClassName(), driver.getDriverClassName()))
                report.line("controllers: %s" %
                            [x.__name__ for x in repository.controllers])

                driver.connect()
                driver.getFolders()

                report = driver.fw_getReport()
            except Exception as e:
                raise
                self.ui.warn("got %s %s" % (repr(e), str(e)))
        report.markdown()


Parser.addAction('examine', Examine, help="examine repositories")
Ejemplo n.º 8
0
@implements(ActionInterface)
class Devel(object):
    """For development purpose only."""

    honorHooks = False
    requireRascal = True

    def __init__(self):
        self._exitCode = 0

    def exception(self, e: ExceptionClass) -> None:
        self._exitCode = 3

    def getExitCode(self) -> int:
        return self._exitCode

    def init(self, parser: Parser) -> None:
        pass

    def run(self) -> None:
        runtime.ui.infoL(1, 'running devel action')

        from ..imap.imap import Imap

        imap = Imap('imaplib2-2.50')
        imap.connect('127.0.0.1', 10143)
        imap.logout()


Parser.addAction('devel', Devel, help="development")
Ejemplo n.º 9
0
from imapfw.interface import implements, checkInterfaces
from imapfw.conf import Parser

from .interface import ActionInterface

# Annotations.
from imapfw.annotation import ExceptionClass


@checkInterfaces()
@implements(ActionInterface)
class Noop(object):
    """The noop action allows testing the loading of the rascal."""

    honorHooks = False
    requireRascal = False

    def exception(self, e: ExceptionClass) -> None:
        raise NotImplementedError

    def getExitCode(self) -> int:
        return 0

    def init(self, parser: Parser) -> None:
        pass

    def run(self) -> None:
        pass

Parser.addAction('noop', Noop, help="test if the rascal can be loaded")
Ejemplo n.º 10
0
        raise NotImplementedError

    def getExitCode(self) -> int:
        return self._exitCode

    def init(self, parser: Parser) -> None:
        pass

    def run(self) -> None:
        import unittest

        from imapfw.types.account import Account
        from imapfw.testing.testrascal import TestRascalAccount

        suite = unittest.TestSuite()

        for def_account in runtime.rascal.getAll([Account]):
            newTest = type(def_account.__name__, (TestRascalAccount,), {})
            newTest.DEF_ACCOUNT = def_account
            suite.addTest(unittest.makeSuite(newTest))

        runner = unittest.TextTestRunner(verbosity=2, failfast=True)
        testResult = runner.run(suite)
        self._setExitCode(len(testResult.failures))

        if testResult.wasSuccessful():
            print("TODO: run tests for the repositories and drivers.")


Parser.addAction('testRascal', TestRascal, help="test your rascal")
Ejemplo n.º 11
0
 def init(self, parser: Parser) -> None:
     self.accountList = parser.get('accounts')
     self.engineName = parser.get('engine')
Ejemplo n.º 12
0
    def run(self) -> None:
        """Enable the syncing of the accounts in an async fashion.

        Code here is about setting up the environment, start the jobs and
        monitor."""


        maxConcurrentAccounts = min(
            runtime.rascal.getMaxSyncAccounts(),
            len(self.accountList))

        accountsArchitect = SyncAccountsArchitect(self.accountList)
        accountsArchitect.start(maxConcurrentAccounts)
        self.exitCode = accountsArchitect.run()


# syncAccounts CLI options.
actionParser = Parser.addAction('syncAccounts',
    SyncAccounts, help="sync on or more accounts")

actionParser.add_argument("-a", "--account", dest="accounts",
    default=[],
    action='append',
    metavar='ACCOUNT',
    required=True,
    help="one or more accounts to sync")

actionParser.add_argument("-e", "--engine", dest="engine",
    default="SyncAccount",
    help="the sync engine")
Ejemplo n.º 13
0
        for cls_account in cls_accounts:
            account = loadAccount(cls_account)
            repositories.append(account.fw_getLeft())
            repositories.append(account.fw_getRight())

        report = Report()
        for repository in repositories:
            if isinstance(repository, DriverInterface):
                continue
            try:
                repository.fw_insertController(ExamineController,
                    {'report': report})
                driver = repository.fw_getDriver()

                report.title("Repository %s (driver %s)"%
                    (repository.getClassName(), driver.getDriverClassName()))
                report.line("controllers: %s"%
                    [x.__name__ for x in repository.controllers])

                driver.connect()
                driver.getFolders()

                report = driver.fw_getReport()
            except Exception as e:
                raise
                self.ui.warn("got %s %s"% (repr(e), str(e)))
        report.markdown()


Parser.addAction('examine', Examine, help="examine repositories")
Ejemplo n.º 14
0
        raise NotImplementedError

    def getExitCode(self) -> int:
        return self._exitCode

    def init(self, parser: Parser) -> None:
        pass

    def run(self) -> None:
        import unittest

        from imapfw.types.account import Account
        from imapfw.testing.testrascal import TestRascalAccount

        suite = unittest.TestSuite()

        for def_account in runtime.rascal.getAll([Account]):
            newTest = type(def_account.__name__, (TestRascalAccount, ), {})
            newTest.DEF_ACCOUNT = def_account
            suite.addTest(unittest.makeSuite(newTest))

        runner = unittest.TextTestRunner(verbosity=2, failfast=True)
        testResult = runner.run(suite)
        self._setExitCode(len(testResult.failures))

        if testResult.wasSuccessful():
            print("TODO: run tests for the repositories and drivers.")


Parser.addAction('testRascal', TestRascal, help="test your rascal")
Ejemplo n.º 15
0
@checkInterfaces()
@implements(ActionInterface)
class Devel(object):
    """For development purpose only."""

    honorHooks = False
    requireRascal = True

    def __init__(self):
        self._exitCode = 0

    def exception(self, e: ExceptionClass) -> None:
        self._exitCode = 3

    def getExitCode(self) -> int:
        return self._exitCode

    def init(self, parser: Parser) -> None:
        pass

    def run(self) -> None:
        runtime.ui.infoL(1, 'running devel action')

        from ..imap.imap import Imap

        imap = Imap('imaplib2-2.50')
        imap.connect('127.0.0.1', 10143)
        imap.logout()

Parser.addAction('devel', Devel, help="development")