def test_TarSCM_config_no_faked_header(self):
     tc_name = inspect.stack()[0][3]
     files   = [ os.path.join(self.fixtures_dir,tc_name,'test.ini') ]
     var     = config(files,False).get('general','apiurl')
     self.assertEqual(var,'http://api.example.com')
     var     = config(files,False).get(var,'email')
     self.assertEqual(var,'*****@*****.**')
Пример #2
0
 def test_TarSCM_config_no_faked_header(self):
     tc_name = inspect.stack()[0][3]
     files   = [
         [os.path.join(self.fixtures_dir, tc_name, 'test.ini'), False]
     ]
     var     = config(files).get('general', 'apiurl')
     self.assertEqual(var, 'http://api.example.com')
     var     = config(files).get(var, 'email')
     self.assertEqual(var, '*****@*****.**')
Пример #3
0
    def get_changesauthor(self, args):
        # return changesauthor if given as cli option
        if args.changesauthor:
            return args.changesauthor
        #

        # find changesauthor in $HOME/.oscrc
        try:
            files = [[os.path.join(os.environ['HOME'], '.oscrc'), False]]
            cfg = config(files)

            changesauthor = None
            section = cfg.get('general', 'apiurl')
            if section:
                changesauthor = cfg.get(section, 'email')
        except KeyError:
            pass

        if not changesauthor:
            changesauthor = TarSCM.cli.DEFAULT_AUTHOR
        #

        logging.debug("AUTHOR: %s", changesauthor)

        return changesauthor
 def test_TarSCM_config_files_ordering(self):
     tc_name = inspect.stack()[0][3]
     files = [
         os.path.join(self.fixtures_dir,tc_name,'a.cfg'),
         os.path.join(self.fixtures_dir,tc_name,'b.cfg'),
     ]
     var = config(files).get(None,'var')
     self.assertEqual(var,'b')
Пример #5
0
 def test_TarSCM_config_files_ordering(self):
     tc_name = inspect.stack()[0][3]
     files = [
         [os.path.join(self.fixtures_dir, tc_name, 'a.cfg'), True],
         [os.path.join(self.fixtures_dir, tc_name, 'b.cfg'), True],
     ]
     var = config(files).get(None, 'var')
     self.assertEqual(var, 'b')
Пример #6
0
    def _calc_repocachedir(self):
        # check for enabled caches (1. local .cache, 2. environment, 3. user config, 4. system wide)
        repocachedir  = None
        cwd = os.getcwd()
        if os.path.isdir(os.path.join(cwd, '.cache')):
            repocachedir = os.path.join(cwd, '.cache')

        if repocachedir is None:
            repocachedir = os.getenv('CACHEDIRECTORY')

        if repocachedir is None:
            repocachedir = config().get('tar_scm', 'CACHEDIRECTORY')

        if repocachedir:
            logging.debug("REPOCACHE: %s", repocachedir)
            self.repohash = self.get_repocache_hash(self.args.subdir)
            self.repocachedir = os.path.join(repocachedir, self.repohash)
    def test_TarSCM_config_debug_tar_scm(self):
        tc_name = inspect.stack()[0][3]

        try:
            tmp = os.environ['DEBUG_TAR_SCM']
        except KeyError:
            tmp = None

        os.environ['DEBUG_TAR_SCM'] = "1"

        files = [os.path.join(self.fixtures_dir,tc_name,'test.rc')]
        var = config(files).get(None,'var')
        self.assertEqual(var,None)
        
        if tmp:
            os.environ['DEBUG_TAR_SCM'] = tmp
        else:
            os.environ['DEBUG_TAR_SCM'] = ''
            os.unsetenv('DEBUG_TAR_SCM')
Пример #8
0
    def test_TarSCM_config_debug_tar_scm(self):
        tc_name = inspect.stack()[0][3]

        try:
            tmp = os.environ['DEBUG_TAR_SCM']
        except KeyError:
            tmp = None

        os.environ['DEBUG_TAR_SCM'] = "1"

        files = [[os.path.join(self.fixtures_dir, tc_name, 'test.rc'), True]]
        var = config(files).get(None, 'var')
        self.assertEqual(var, None)

        if tmp:
            os.environ['DEBUG_TAR_SCM'] = tmp
        else:
            os.environ['DEBUG_TAR_SCM'] = ''
            os.unsetenv('DEBUG_TAR_SCM')
    def get_changesauthor(self, args):
        # return changesauthor if given as cli option
        if args.changesauthor:
            return args.changesauthor
        #

        # find changesauthor in $HOME/.oscrc
        files = [os.path.join(os.environ['HOME'],'.oscrc')]
        cfg = config(files,False)

        changesauthor = None
        section = cfg.get('general','apiurl')
        if section:
                changesauthor = cfg.get(section,'email')
        if not changesauthor:
                changesauthor = TarSCM.cli.DEFAULT_AUTHOR
        #

        logging.debug("AUTHOR: %s", changesauthor)

        return changesauthor
Пример #10
0
    def _calc_repocachedir(self):
        # check for enabled caches in this order (first wins):
        #   1. local .cache
        #   2. environment
        #   3. user config
        #   4. system wide
        repocachedir = None
        cwd = os.getcwd()
        if os.path.isdir(os.path.join(cwd, '.cache')):
            repocachedir = os.path.join(cwd, '.cache')

        if repocachedir is None:
            repocachedir = os.getenv('CACHEDIRECTORY')

        if repocachedir is None:
            repocachedir = config().get('tar_scm', 'CACHEDIRECTORY')

        if repocachedir:
            logging.debug("REPOCACHE: %s", repocachedir)
            self.repohash = self.get_repocache_hash(self.args.subdir)
            self.repocachedir = os.path.join(repocachedir, self.repohash)