Esempio n. 1
0
 def test_run_class(self):
     enabled_classes = {'test': 'testManager.staticmockclass'}
     argv = ["test", "mymethod", "myarg"]
     defaults = {
         'datadir': 'data',
         'loglevel': 'INFO',
         'logfile': None,
         'staticmock': {}
     }
     config = manager._load_config(argv=argv, defaults=defaults)
     self.assertEqual(manager._run_class(enabled_classes, argv, config),
                      "ok!")
Esempio n. 2
0
 def test_run_class(self):
     enabled_classes = {'test': 'testManager.staticmockclass'}
     argv = ["test", "mymethod", "myarg"]
     defaults = {'datadir': 'data',
                 'loglevel': 'INFO',
                 'logfile': None,
                 'staticmock': {}}
     config = manager._load_config(argv=argv, defaults=defaults)
     self.assertEqual(manager._run_class(enabled_classes,
                                         argv,
                                         config),
                      "ok!")
Esempio n. 3
0
 def test_config_init(self):
     # make sure that the sub-config object created by run() is
     # identical to the config object used by the instance
     manager.config_loaded = False
     self._enable_repos()
     argv = ['test', 'inspect', 'config']
     ourcfg = manager._load_config(argv=argv,
                                   defaults={'loglevel': 'CRITICAL',
                                             'logfile': None,
                                             'datadir': 'data',
                                             'profile': False,
                                             'test': {'hello': 'world'}})
     with patch('ferenda.manager._load_config', return_value=ourcfg):
         instcfg = manager.run(argv)
         self.assertIsInstance(instcfg, LayeredConfig)
         self.assertEqual(id(ourcfg.test),
                          id(instcfg))
Esempio n. 4
0
 def test_config_init(self):
     # make sure that the sub-config object created by run() is
     # identical to the config object used by the instance
     manager.config_loaded = False
     self._enable_repos()
     argv = ['test', 'inspect', 'config']
     ourcfg = manager._load_config(argv=argv,
                                   defaults={
                                       'loglevel': 'CRITICAL',
                                       'logfile': None,
                                       'datadir': 'data',
                                       'profile': False,
                                       'test': {
                                           'hello': 'world'
                                       }
                                   })
     with patch('ferenda.manager._load_config', return_value=ourcfg):
         instcfg = manager.run(argv)
         self.assertIsInstance(instcfg, LayeredConfig)
         self.assertEqual(id(ourcfg.test), id(instcfg))
Esempio n. 5
0
sys.path.append("..")
from ferenda import util
from ferenda.manager import _load_config, _load_class, _instantiate_class, _enabled_classes

optionsfile = sys.argv[1]
assert os.path.exists(optionsfile)
repos = sys.argv[2:]
assert repos
remove = True  # set this to True manually when you're really really sure
count= {"unreferenced": 0,
        "metadataonly": 0,
        "removed": 0}

# 1 load ferenda.conf to instantiate repos with proper options
configpath = "ferenda.ini"
config = _load_config(configpath)
insts = {}
# 2 for each repo, list all available basefiles
metadataonly = []
for repo in repos:
    cls = _load_class(_enabled_classes("ferenda.ini")[repo])
    inst = _instantiate_class(cls, config)
    insts[repo] = inst
    for basefile in inst.store.list_basefiles_for("parse"):
        #   2.1 if deppath(basefile) doesn't exist or is empty
        deppath = inst.store.dependencies_path(basefile)
        if not os.path.exists(deppath) or os.path.getsize(deppath) == 0:
            print("%s %s: unreferenced document" % (repo, basefile))
            #   2.3 add (repo, basefile) to internal metadataonly-list
            metadataonly.append((repo, basefile))
count["unreferenced"] = len(metadataonly)            
Esempio n. 6
0
def getconfig(basedir):
    defaults = dict(DEFAULT_CONFIG)
    os.environ['FERENDA_SERIALIZEUNPARSED'] = basedir
    return _load_config(_find_config_file())
Esempio n. 7
0
def getconfig(basedir):
    defaults = dict(DEFAULT_CONFIG)
    os.environ['FERENDA_SERIALIZEUNPARSED'] = basedir
    return _load_config(_find_config_file())