示例#1
0
    def test_file_content(self):
        '''Test file content for all files for all child classes of the
        ProjectBase class.
        '''

        for project_cls in CLASSES:
            with TMPFile() as rootdir:
                with TMPFile(root=rootdir) as project:
                    print_header('Testing file content for class '
                                 '`{0}`'.format(project_cls.__name__))
                    project_cls.create_all(rootdir, project)

                    gendir = os.path.join(rootdir, project)
                    tpath = project_cls.template_path()
                    _, files = entree.utils.get_all_dirs_and_files(tpath)
                    filmap = entree.utils.filemap(files,
                                                  replace=project_cls.replace,
                                                  modname=project)
                    for tname, fname in filmap.items():
                        six.print_('- Testing file content for '
                                   '`{0}`'.format(fname))
                        filepath = os.path.join(gendir, fname)
                        templatepath = project_cls.template_path()
                        templatepath = os.path.join(templatepath, tname)
                        content1, content2 = get_file_content(
                            project,
                            filepath,
                            templatepath,
                            project_cls=project_cls)
                        self.assertEqual(content1, content2)
示例#2
0
    def test_file_creation(self):
        '''Test that all files are created where they should be
        for all child classes of the ProjectBase class.
        '''
        # Loop through all classes available in entree.projects
        for project_cls in CLASSES:
            # Create temporary rootdir
            with TMPFile() as rootdir:
                # Create temporary project directory
                with TMPFile(root=rootdir) as project:
                    print_header('Testing file creation for class '
                                 '`{0}`'.format(project_cls.__name__))
                    project_cls.create_all(rootdir, project)
                    gendir = os.path.join(rootdir, project)

                    tpath = project_cls.template_path()
                    _, files = entree.utils.get_all_dirs_and_files(tpath)
                    filmap = entree.utils.filemap(files,
                                                  replace=project_cls.replace,
                                                  modname=project)
                    for _, fname in filmap.items():
                        six.print_('- Testing file `{0}`'.format(fname))
                        path = os.path.join(gendir, fname)
                        try:
                            self.assertTrue(os.path.exists(path))
                        except AssertionError:
                            six.print_('\nERROR: Path does not exist: '
                                       '{0}'.format(path))
                            raise
示例#3
0
    def test_file_creation(self):
        '''Test that all files are created where they should be
        for all child classes of the ProjectBase class.
        '''
        # Loop through all classes available in entree.projects
        for project_cls in CLASSES:
            # Create temporary rootdir
            with TMPFile() as rootdir:
                # Create temporary project directory
                with TMPFile(root=rootdir) as project:
                    print_header('Testing file creation for class '
                                 '`{0}`'.format(project_cls.__name__))
                    project_cls.create_all(rootdir, project)
                    gendir = os.path.join(rootdir, project)

                    tpath = project_cls.template_path()
                    _, files = entree.utils.get_all_dirs_and_files(tpath)
                    filmap = entree.utils.filemap(files,
                                                  replace=project_cls.replace,
                                                  modname=project)
                    for _, fname in filmap.items():
                        six.print_('- Testing file `{0}`'.format(fname))
                        path = os.path.join(gendir, fname)
                        try:
                            self.assertTrue(os.path.exists(path))
                        except AssertionError:
                            six.print_('\nERROR: Path does not exist: '
                                       '{0}'.format(path))
                            raise
示例#4
0
    def test_file_content(self):
        '''Test file content for all files for all child classes of the
        ProjectBase class.
        '''

        for project_cls in CLASSES:
            with TMPFile() as rootdir:
                with TMPFile(root=rootdir) as project:
                    print_header('Testing file content for class '
                                 '`{0}`'.format(project_cls.__name__))
                    project_cls.create_all(rootdir, project)

                    gendir = os.path.join(rootdir, project)
                    tpath = project_cls.template_path()
                    _, files = entree.utils.get_all_dirs_and_files(tpath)
                    filmap = entree.utils.filemap(files,
                                                  replace=project_cls.replace,
                                                  modname=project)
                    for tname, fname in filmap.items():
                        six.print_('- Testing file content for '
                                   '`{0}`'.format(fname))
                        filepath = os.path.join(gendir, fname)
                        templatepath = project_cls.template_path()
                        templatepath = os.path.join(templatepath, tname)
                        content1, content2 = get_file_content(
                            project, filepath, templatepath,
                            project_cls=project_cls
                        )
                        self.assertEqual(content1, content2)
示例#5
0
    def test_partial_file_creation(self):
        '''Test that all files are created where they should be
        for all child classes of the ProjectBase class.
        '''
        # Loop through all classes available in entree.projects
        for project_cls in CLASSES:
            # Create temporary rootdir
            config = project_cls.get_config()
            if 'partial_builds' in config:
                for partial_build in config['partial_builds']:
                    with TMPFile() as rootdir:
                        # Create temporary project directory
                        with TMPFile(root=rootdir) as project:
                            print_header('Testing partial file creation for '
                                         'class '
                                         '`{0}`'.format(project_cls.__name__))
                            project_cls.create_all(rootdir,
                                                   project,
                                                   partial=partial_build)
                            gendir = os.path.join(rootdir, project)

                            tpath = project_cls.template_path()
                            files = entree.utils.get_all_dirs_and_files(tpath)
                            filmap = entree.utils.filemap(
                                files[1],
                                replace=project_cls.replace,
                                modname=project)
                            partials = config['partial_builds'][partial_build]
                            for tname, fname in filmap.items():
                                path = os.path.join(gendir, fname)
                                if tname in partials:
                                    six.print_('- Testing file '
                                               '`{0}`: IN'.format(fname))
                                    try:
                                        self.assertTrue(os.path.exists(path))
                                    except AssertionError:
                                        six.print_('\nERROR: Path does not '
                                                   'exist: {0}'.format(path))
                                        raise
                                else:
                                    six.print_('- Testing file '
                                               '`{0}`: OUT'.format(fname))
                                    try:
                                        self.assertFalse(os.path.exists(path))
                                    except AssertionError:
                                        six.print_('\nERROR: Path does '
                                                   'exist: {0}'.format(path))
                                        raise
示例#6
0
    def test_partial_file_creation(self):
        '''Test that all files are created where they should be
        for all child classes of the ProjectBase class.
        '''
        # Loop through all classes available in entree.projects
        for project_cls in CLASSES:
            # Create temporary rootdir
            config = project_cls.get_config()
            if 'partial_builds' in config:
                for partial_build in config['partial_builds']:
                    with TMPFile() as rootdir:
                        # Create temporary project directory
                        with TMPFile(root=rootdir) as project:
                            print_header('Testing partial file creation for '
                                         'class '
                                         '`{0}`'.format(project_cls.__name__))
                            project_cls.create_all(rootdir, project,
                                                   partial=partial_build)
                            gendir = os.path.join(rootdir, project)

                            tpath = project_cls.template_path()
                            files = entree.utils.get_all_dirs_and_files(tpath)
                            filmap = entree.utils.filemap(
                                files[1],
                                replace=project_cls.replace,
                                modname=project
                            )
                            partials = config['partial_builds'][partial_build]
                            for tname, fname in filmap.items():
                                path = os.path.join(gendir, fname)
                                if tname in partials:
                                    six.print_('- Testing file '
                                               '`{0}`: IN'.format(fname))
                                    try:
                                        self.assertTrue(os.path.exists(path))
                                    except AssertionError:
                                        six.print_('\nERROR: Path does not '
                                                   'exist: {0}'.format(path))
                                        raise
                                else:
                                    six.print_('- Testing file '
                                               '`{0}`: OUT'.format(fname))
                                    try:
                                        self.assertFalse(os.path.exists(path))
                                    except AssertionError:
                                        six.print_('\nERROR: Path does '
                                                   'exist: {0}'.format(path))
                                        raise
示例#7
0
    def test_directory_creation(self):
        '''Test that all directories are created where they should be
        for all child classes of the ProjectBase class.
        '''
        # Loop through all classes available in entree.projects
        for project_cls in CLASSES:
            # Create temporary rootdir
            with TMPFile() as rootdir:
                # Create temporary project directory
                with TMPFile(root=rootdir) as project:
                    print_header('Testing directory creation for class '
                                 '`{0}` with files to '
                                 'ignore'.format(project_cls.__name__))
                    project_cls.create_all(rootdir, project)
                    config = project_cls.get_config()
                    files_to_ignore = []
                    if 'files_to_ignore' in config:
                        files_to_ignore = config['files_to_ignore']
                    six.print_('Files to ignore: ', files_to_ignore)

                    gendir = os.path.join(rootdir, project)

                    tpath = project_cls.template_path()
                    dirs, _ = entree.utils.get_all_dirs_and_files(
                        tpath,
                        files_to_ignore=files_to_ignore
                    )
                    dirmap = entree.utils.filemap(dirs,
                                                  replace=project_cls.replace,
                                                  modname=project)

                    for _, dname in dirmap.items():
                        six.print_('- Testing directory `{0}`'.format(dname))
                        path = os.path.join(gendir, dname)
                        try:
                            self.assertTrue(os.path.exists(path))
                        except AssertionError:
                            six.print_('\nERROR: Path does not exist: '
                                       '{0}'.format(path))
                            raise
示例#8
0
 def test_single_file_creation(self):
     '''Test file creation in single-file mode
     for all child classes of the ProjectBase class.
     '''
     # Loop through all classes available in entree.projects
     for project_cls in CLASSES:
         if project_cls.single_file:
             # Create temporary rootdir
             with TMPFile() as rootdir:
                 # Create temporary project directory
                 with TMPFile(root=rootdir) as project:
                     print_header('Testing single-file creation for class '
                                  '`{0}`'.format(project_cls.__name__))
                     gendir = os.path.join(rootdir, project)
                     project_cls.create_one(gendir, 'somefile.txt')
                     path = os.path.join(gendir, 'somefile.txt')
                     try:
                         self.assertTrue(os.path.exists(path))
                     except AssertionError:
                         six.print_('\nERROR: Path does not exist: '
                                    '{0}'.format(path))
                         raise
示例#9
0
 def test_single_file_content(self):
     '''Test file content in single-file mode
     for all child classes of the ProjectBase class.
     '''
     # Loop through all classes available in entree.projects
     for project_cls in CLASSES:
         if project_cls.single_file:
             # Create temporary rootdir
             with TMPFile() as rootdir:
                 # Create temporary project directory
                 with TMPFile(root=rootdir) as project:
                     print_header('Testing single-file content for class '
                                  '`{0}`'.format(project_cls.__name__))
                     gendir = os.path.join(rootdir, project)
                     project_cls.create_one(gendir, 'somefile.txt')
                     filepath = os.path.join(gendir, 'somefile.txt')
                     templatepath = project_cls.single_file_path()
                     content1, content2 = get_file_content(
                         'somefile', filepath, templatepath,
                         project_cls=project_cls
                     )
                     self.assertEqual(content1, content2)
示例#10
0
 def test_single_file_creation(self):
     '''Test file creation in single-file mode
     for all child classes of the ProjectBase class.
     '''
     # Loop through all classes available in entree.projects
     for project_cls in CLASSES:
         if project_cls.single_file:
             # Create temporary rootdir
             with TMPFile() as rootdir:
                 # Create temporary project directory
                 with TMPFile(root=rootdir) as project:
                     print_header('Testing single-file creation for class '
                                  '`{0}`'.format(project_cls.__name__))
                     gendir = os.path.join(rootdir, project)
                     project_cls.create_one(gendir, 'somefile.txt')
                     path = os.path.join(gendir, 'somefile.txt')
                     try:
                         self.assertTrue(os.path.exists(path))
                     except AssertionError:
                         six.print_('\nERROR: Path does not exist: '
                                    '{0}'.format(path))
                         raise
示例#11
0
    def test_directory_creation(self):
        '''Test that all directories are created where they should be
        for all child classes of the ProjectBase class.
        '''
        # Loop through all classes available in entree.projects
        for project_cls in CLASSES:
            # Create temporary rootdir
            with TMPFile() as rootdir:
                # Create temporary project directory
                with TMPFile(root=rootdir) as project:
                    print_header('Testing directory creation for class '
                                 '`{0}` with files to '
                                 'ignore'.format(project_cls.__name__))
                    project_cls.create_all(rootdir, project)
                    config = project_cls.get_config()
                    files_to_ignore = []
                    if 'files_to_ignore' in config:
                        files_to_ignore = config['files_to_ignore']
                    six.print_('Files to ignore: ', files_to_ignore)

                    gendir = os.path.join(rootdir, project)

                    tpath = project_cls.template_path()
                    dirs, _ = entree.utils.get_all_dirs_and_files(
                        tpath, files_to_ignore=files_to_ignore)
                    dirmap = entree.utils.filemap(dirs,
                                                  replace=project_cls.replace,
                                                  modname=project)

                    for _, dname in dirmap.items():
                        six.print_('- Testing directory `{0}`'.format(dname))
                        path = os.path.join(gendir, dname)
                        try:
                            self.assertTrue(os.path.exists(path))
                        except AssertionError:
                            six.print_('\nERROR: Path does not exist: '
                                       '{0}'.format(path))
                            raise
示例#12
0
 def test_single_file_content(self):
     '''Test file content in single-file mode
     for all child classes of the ProjectBase class.
     '''
     # Loop through all classes available in entree.projects
     for project_cls in CLASSES:
         if project_cls.single_file:
             # Create temporary rootdir
             with TMPFile() as rootdir:
                 # Create temporary project directory
                 with TMPFile(root=rootdir) as project:
                     print_header('Testing single-file content for class '
                                  '`{0}`'.format(project_cls.__name__))
                     gendir = os.path.join(rootdir, project)
                     project_cls.create_one(gendir, 'somefile.txt')
                     filepath = os.path.join(gendir, 'somefile.txt')
                     templatepath = project_cls.single_file_path()
                     content1, content2 = get_file_content(
                         'somefile',
                         filepath,
                         templatepath,
                         project_cls=project_cls)
                     self.assertEqual(content1, content2)