def testItShouldNotInstallAnArchivedLocalModuleIfAlreadyPresent(self): ModuleInstaller("./tmp").install(["./test/mwr_test/mocks/a.local.zip"]) assert os.path.exists("./tmp/a") assert os.path.exists("./tmp/a/__init__.py") assert os.path.exists("./tmp/a/local") assert os.path.exists("./tmp/a/local/__init__.py") assert os.path.exists("./tmp/a/local/module.py") ModuleInstaller("./tmp").install( ["./test/mwr_test/mocks(reinstall)/a.local.zip"]) assert fs.read("./tmp/a/local/module.py" ) != "This is an edited local, archived module.\n"
def testItShouldOverwriteAnArchivedLocalModuleIfForceIsSet(self): ModuleInstaller("./tmp").install(["./test/mwr_test/mocks/a.local.zip"]) assert os.path.exists("./tmp/a") assert os.path.exists("./tmp/a/__init__.py") assert os.path.exists("./tmp/a/local") assert os.path.exists("./tmp/a/local/__init__.py") assert os.path.exists("./tmp/a/local/module.py") ModuleInstaller("./tmp").install( ["./test/mwr_test/mocks/mocks(reinstall)/a.local.zip"], True) assert fs.read("./tmp/a/local/module.py" ) == "This is an edited local, archived module.\n"
def do_install(self, arguments): """install a new module""" repository = self.__choose_repo() if repository != None: installer = ModuleInstaller(repository) modules = installer.install(arguments.options) print print "Successfully installed %d modules, %d already installed." % (len(modules['success']), len(modules['existing'])) if len(modules['fail']) > 0: print "Failed to install %d modules:" % len(modules['fail']) for module in modules['fail']: print " %s" % module print " %s" % modules['fail'][module] print
def setUp(self): Configuration._Configuration__config = ConfigParser.SafeConfigParser() shutil.rmtree("./tmp", True) shutil.rmtree("./repo", True) Repository.create("./tmp") fs.write("./tmp/a.local.module", "This is a local, raw module.") ModuleInstaller("./tmp").install(["./tmp/a.local.module"])
def do_install(self, arguments): """install a new module""" repository = self.__choose_repo() if repository != None: installer = ModuleInstaller(repository) modules = installer.install(arguments.options, arguments.force) print print "Successfully installed %d modules, %d already installed." % ( len(modules['success']), len(modules['existing'])) if len(modules['fail']) > 0: print "Failed to install %d modules:" % len(modules['fail']) for module in modules['fail']: print " %s" % module print " %s" % modules['fail'][module] print
def __search_remotes(self, term, include_descriptions=False): """ Search for modules, on remote repositories. """ installer = ModuleInstaller(None) modules = installer.search_index(term) if len(modules) > 0: for module in modules: print module if include_descriptions: if module.description != None: print "%s\n" % text.indent(text.wrap(module.description, console.get_size()[0] - 4), " ") else: print text.indent("No description given.\n", " ") print else: print "No modules found.\n"
def testItShouldInstallAnArchiveModuleFromALocalSource(self): ModuleInstaller("./tmp").install(["./test/mwr_test/mocks/a.local.zip"]) assert os.path.exists("./tmp/a") assert os.path.exists("./tmp/a/__init__.py") assert os.path.exists("./tmp/a/local") assert os.path.exists("./tmp/a/local/__init__.py") assert os.path.exists("./tmp/a/local/module.py") assert fs.read( "./tmp/a/local/module.py") == "This is a local, archived module.\n"
def testItShouldNotInstallARawLocalModuleIfAlreadyPresent(self): fs.write("./tmp/a.local.module", "This is a local, raw module.") ModuleInstaller("./tmp").install(["./tmp/a.local.module"]) assert os.path.exists("./tmp/a") assert os.path.exists("./tmp/a/__init__.py") assert os.path.exists("./tmp/a/local") assert os.path.exists("./tmp/a/local/__init__.py") assert os.path.exists("./tmp/a/local/module.py") assert fs.read( "./tmp/a/local/module.py") == "This is a local, raw module." fs.write("./tmp/a.local.module", "This is an edited local, raw module.") ModuleInstaller("./tmp").install(["./tmp/a.local.module"]) assert fs.read("./tmp/a/local/module.py" ) != "This is an edited local, raw module."
def __search_remotes(self, term, include_descriptions=False): """ Search for modules, on remote repositories. """ installer = ModuleInstaller(None) modules = installer.search_index(term) if len(modules) > 0: for module in modules: print module if include_descriptions: if module.description != None: print "%s\n" % text.indent( text.wrap(module.description, console.get_size()[0] - 4), " ") else: print text.indent("No description given.\n", " ") print else: print "No modules found.\n"
def testItShouldOverwriteARawLocalModuleIfForceIsSet(self): fs.write("./tmp/a.local.module", "This is a local, raw module.") ModuleInstaller("./tmp").install(["./tmp/a.local.module"]) assert os.path.exists("./tmp/a") assert os.path.exists("./tmp/a/__init__.py") assert os.path.exists("./tmp/a/local") assert os.path.exists("./tmp/a/local/__init__.py") assert os.path.exists("./tmp/a/local/module.py") assert fs.read( "./tmp/a/local/module.py") == "This is a local, raw module." fs.write("./tmp/a.local.module", "This is an edited local, raw module.") ModuleInstaller("./tmp").install(["./tmp/a.local.module"], True) assert fs.read("./tmp/a/local/module.py" ) == "This is an edited local, raw module."
def testItShouldInstallARawModuleFromALocalSource(self): fs.write("./tmp/a.local.module", "This is a local, raw module.") ModuleInstaller("./tmp").install(["./tmp/a.local.module"]) assert os.path.exists("./tmp/a") assert os.path.exists("./tmp/a/__init__.py") assert os.path.exists("./tmp/a/local") assert os.path.exists("./tmp/a/local/__init__.py") assert os.path.exists("./tmp/a/local/module.py") assert fs.read( "./tmp/a/local/module.py") == "This is a local, raw module."