Ejemplo n.º 1
0
    def __init__(self, init_session=True, **kwargs):
        if kwargs:
            # If kwargs have been supplied, use these in same way argsparse
            # would.
            # Mainly used for testing, but could be used to run commands from
            # within python scripts.

            # We can't add attributes to instances of Object, so we need create
            # a new class.
            class Args(object):
                pass

            self.args = Args()
            for key, value in kwargs.items():
                setattr(self.args, key, value)
        else:
            # If the command is created from the command line, we'll have
            # arguments to parse.
            parser = argparse.ArgumentParser(
                description="Taming the bull: Change management for Agresso systems")
            self._add_arguments(parser)
            self.args, unknown = parser.parse_known_args()

        self._logger = logging.getLogger(__name__)
        if init_session:
            Session.initialise()
        self._execute()
Ejemplo n.º 2
0
def test_initialise(project_repo):
    Session.initialise()
    assert Session.project_folder == Path(project_repo.path)
    assert Session.project == project
    assert Session.matador_project_folder == Path(
        Path.home(), '.matador', project)
    assert Session.matador_repository_folder == Path(
        Path.home(), '.matador', project, 'repository')
    assert Session.environments == environments