def _pre_start_neovim(self): super()._pre_start_neovim() self.base = temp_dir('projects', 'base') self.base2 = temp_dir('projects', 'base2') self.typed1 = 'type1' self.type1_base = temp_dir('projects', self.typed1) self.type_bases = Map({self.type1_base: List(self.typed1)})
def setup(self): ribosome.in_vim = False super().setup() self.logfile = temp_dir('log') / 'proteome_spec' self.vimlog = temp_dir('log') / 'vim' self.logfile.touch() amino.logging.logfile = self.logfile amino.logging.amino_file_logging(handler_level=logging.WARN) argv = ['nvim', '--embed', '-V{}'.format(self.vimlog), '-u', 'NONE'] self.neovim = neovim.attach('child', argv=argv) NvimFacade.async = _mock_async NvimFacade.main_event_loop = _nop_main_loop NvimFacade.proxy = property(_mock_proxy) NvimFacade.clean = lambda self: True self.proteome = ProteomeNvimPlugin(self.neovim) self.vim = self.proteome.vim self.vim.vars.set_p('config_path', str(self.config)) self.vim.vars.set_p('base_dirs', List(str(self.base))) self.vim.vars.set_p('type_base_dirs', self.type_bases.keymap(str)) self.vim.vars.set_p('history_base', str(self.history_base)) self.vim.vars.set_p('plugins', List('proteome.plugins.history', 'proteome.plugins.ctags', 'proteome.plugins.config', 'proteome.plugins.unite', )) self.pros = self.add_projects( ('python', 'pro1'), ('python', 'pro2'), ('vim', 'pro3'))
def setup(self): super().setup() self.base = temp_dir('projects', 'base') self.config = fixture_path('conf') self.type1 = 'type1' self.type1_base = temp_dir('projects', self.type1) self.type_bases = Map({self.type1_base: List(self.type1)})
def crm_rplugin_spec() -> Do: temp_dir('rplugin', 'venv', name, 'lib', 'python3.7') yield request('init') data = yield NS.inspect(lambda a: a.data) rplugin = data.chromatin_rplugin.to_either('no chromatin rplugin') venv = data.chromatin_venv.to_either('no chromatin venv') return ( k(rplugin).must(be_right(DistRplugin.cons('chromatin', 'chromatin'))) & k(venv).must(eq(rplugin / _.name)))
def complete_addable(self): def check(pre, ident): idents = self.proteome.pro_complete_addable_projects([pre, '', '']) set(idents).should.equal(set(ident)) pro4n = 'pro4' pro4 = '{}/{}'.format(self.type1, pro4n) temp_dir(self.type1_base / pro4n) self.proteome.proteome_start() self._await() check('', ['python/pro1', 'python/pro2', 'vim/pro3', pro4]) check('py', ['python/pro1', 'python/pro2']) check('type1', [pro4])
def add_by_params(self): tpe = 'ptype' name = 'pname' root = temp_dir('proteome/add_by_params') params = Map( type=tpe, root=root ) with self._prot() as prot: ret = prot.send_sync(AddByParams(name, params)) (ret.project(name) / _.root).should.contain(root)
def setup(self): super().setup() self.pypro1_type = 'python' self.pypro1_name = 'pypro1' self.pypro2_name = 'pypro2' self.config = Path(fixture_path('conf')) self.project_base = Path(temp_dir('projects')) self.project_base2 = Path(temp_dir('projects2')) self.pypro1_root = self.mk_project_root(self.pypro1_type, self.pypro1_name) self.mk_project_root(self.pypro1_type, self.pypro2_name, self.project_base2) self.mk_project_root('other', 'other2', self.project_base2) self.type1_base = Path(temp_dir('type1_projects')) self.type1pro_name = 'type1pro' self.type1pro_root = temp_dir(self.type1_base / self.type1pro_name) self.type_bases = Map({self.type1_base: List('type1')}) self.resolver = Resolver(List(self.project_base, self.project_base2), self.type_bases) self.loader = ProjectLoader(self.config, self.resolver)
def add_by_params(self): tpe = 'ptype' name = 'pname' ident = '{}/{}'.format(tpe, name) root = temp_dir('plugin/from_params') params = Map( root=str(root), history=False, ) self.proteome.proteome_start() self.proteome.pro_add([ident] + json.dumps(params).split(' ')) self._await() self._projects.last.should.contain(Project.of(name, root, Just(tpe)))
def from_params(self): tpe = 'ptype' name = 'pname' ident = '{}/{}'.format(tpe, name) root = temp_dir('loader/from_params') types = List('a', 'b') langs = List('c', 'd') params = Map( types=types, langs=langs, history=False, ) pro = self.loader.from_params(ident, root, params) pro.should.contain(Project.of(name, root, Just(tpe))) pro.x.types.should.equal(types) pro.x.langs.should.equal(langs) pro.x.history.should_not.be.ok
def single_venv_config(name: str, spec: str, **extra_vars: Any) -> Tuple[Rplugin, Venv, TestConfig]: rplugin = simple_rplugin(name, spec) dir = temp_dir('rplugin', 'venv') vars = Map(chromatin_venv_dir=str(dir))**Map(extra_vars) conf = lens.basic.state_ctor.set(LogBufferEnv.cons)(chromatin_config) venv = Venv( rplugin.name, VenvMeta(name, dir / name, Right(Path('/dev/null')), Right(Path('/dev/null')))) return rplugin, venv, TestConfig.cons( conf, vars=vars, io_interpreter=single_venv_io_interpreter(venv), logger=buffering_logger, function_handler=test_function_handler(exists=1), command_handler=test_command_handler(), )
from ribosome.nvim.io.state import NS from ribosome.data.plugin_state import PS from ribosome.test.unit import update_data, unit_test from ribosome.test.prog import request from test.base import rplugin_dir, single_venv_config from amino import List, do, Do from amino.test.spec import SpecBase from amino.test import temp_dir from chromatin.util import resources name = 'flagellum' spec = rplugin_dir(name) dir = temp_dir('rplugin', 'venv') rplugin, venv, conf = single_venv_config( name, spec, chromatin_rplugins=[dict(name=name, spec=spec)], chromatin_venv_dir=str(dir), ) @do(NS[PS, Expectation]) def one_spec() -> Do: yield update_data(rplugins=List(rplugin)) yield request('show_plugins') log_buffer = yield NS.inspect(lambda a: a.data.log_buffer) return k(log_buffer).must( contain(Echo.info(resources.show_plugins(dir, List(rplugin)))))
def setup_venv_dir(venv_dir: Maybe[Path] = Nothing) -> Do: rtp = fixture_path('rplugin', 'config', 'rtp') yield option_cat('runtimepath', List(rtp)) dir = venv_dir | temp_dir('rplugin', 'venv') yield variable_set_prefixed('venv_dir', str(dir)) return dir
def mk_project_root(self, tpe, name, base=None): base = base or self.project_base root = temp_dir(str(base / tpe / name)) root.mkdir(parents=True, exist_ok=True) return Path(root)
def _mk_projects(self): self.other = 'other' self.other2 = 'other2' temp_dir(str(self.type1_base / self.other)) temp_dir(str(self.base2 / self.tpe1 / self.other2))
def setup(self): super().setup() self.temp_projects = Path(temp_dir('projects')) self.history_base = Path(temp_dir('history'))
def mk_project(self, name, tpe): root = temp_dir(str(self.temp_projects / tpe / name)) return Project.of(name, Path(root), tpe=Just(tpe))
def from_params_no_type(self): name = 'pname' root = temp_dir('loader/from_params') pro = self.loader.from_params(name, root, Map()) pro.should.contain(Project.of(name, root, Empty()))