Exemplo n.º 1
0
 def test_new_directory_contents(self, dir_function):
     name = 'testdirectory_001'
     os.chdir(dir_function.path)
     utils.create_test_dir(name)
     testdir = os.path.join(dir_function.path, name)
     listdir = os.listdir(testdir)
     files = [
         name for name in listdir
         if os.path.isfile(os.path.join(testdir, name))
     ]
     dirs = [
         name for name in listdir
         if os.path.isdir(os.path.join(testdir, name))
     ]
     if '.DS_Store' in files:
         files.remove('.DS_Store')
     assert len(files) == 4
     # verify files
     assert '__init__.py' in files
     assert 'settings.json' in files
     assert 'users.json' in files
     assert '.golem' in files
     # verify directories
     assert len(dirs) == 2
     # verify the test dir contains the correct directories
     assert 'projects' in dirs
     assert 'drivers' in dirs
Exemplo n.º 2
0
def createdirectory_command(dir_name):
    """Generate a new 'golem' directory"""
    if os.path.exists(dir_name):
        msg = ('golem-admin createdirectory: error: the directory {} '
               'already exists'.format(dir_name))
        sys.exit(msg)
    else:
        destination = os.path.join(os.getcwd(), dir_name)
        utils.create_test_dir(destination)
Exemplo n.º 3
0
    def run(self, args):
        # Generate a new 'golem' directory
        dir_name = args.name

        if os.path.exists(dir_name):
            raise CommandException(
                'Error: the directory {} already exists'.format(dir_name))

        destination = os.path.join(os.getcwd(), dir_name)
        utils.create_test_dir(destination)
Exemplo n.º 4
0
    def run(self, args):
        # Generate a new 'golem' directory
        dir_name = args.name

        if os.path.exists(dir_name):
            raise CommandException(
                'Error: the directory {} already exists'.format(dir_name)
            )

        destination = os.path.join(os.getcwd(), dir_name)
        utils.create_test_dir(destination)
Exemplo n.º 5
0
def createdirectory_command(dir_name, no_confirm=False):
    """Create a new Golem test directory

    dir_name must be an absolute or relative path.
    If the path exists and is not empty and no_confirm
    is False the user will be prompted to continue.
    """
    abspath = os.path.abspath(dir_name)
    if os.path.exists(abspath) and os.listdir(abspath):
        # directory is not empty
        if not no_confirm:
            msg = 'Directory {} is not empty, continue? [Y/n]'.format(dir_name)
            if not utils.prompt_yes_no(msg):
                return
        if os.path.isfile(os.path.join(abspath, '.golem')):
            sys.exit(
                'Error: target directory is already an existing Golem test directory'
            )
    utils.create_test_dir(abspath)