How to use _get_extensions method in avocado

Best Python code snippet using avocado_python

test_jupyterlab.py

Source:test_jupyterlab.py Github

copy

Full Screen

...98 def test_install_extension(self):99 install_extension(self.source_dir)100 path = pjoin(self.app_dir, 'extensions', '*python-tests*.tgz')101 assert glob.glob(path)102 assert '@jupyterlab/python-tests' in _get_extensions(self.app_dir)103 def test_install_twice(self):104 install_extension(self.source_dir)105 path = pjoin(commands.get_app_dir(), 'extensions', '*python-tests*.tgz')106 install_extension(self.source_dir)107 assert glob.glob(path)108 assert '@jupyterlab/python-tests' in _get_extensions(self.app_dir)109 def test_install_mime_renderer(self):110 install_extension(self.mime_renderer_dir)111 assert '@jupyterlab/mime-extension-test' in _get_extensions(self.app_dir)112 uninstall_extension('@jupyterlab/mime-extension-test')113 assert '@jupyterlab/mime-extension-test' not in _get_extensions(self.app_dir)114 def test_install_incompatible(self):115 with pytest.raises(ValueError) as excinfo:116 install_extension(self.incompat_dir)117 assert 'Conflicting Dependencies' in str(excinfo.value)118 def test_install_failed(self):119 path = self.mock_package120 with pytest.raises(ValueError):121 install_extension(path)122 with open(pjoin(path, 'package.json')) as fid:123 data = json.load(fid)124 assert not data['name'] in _get_extensions(self.app_dir)125 def test_uninstall_extension(self):126 install_extension(self.source_dir)127 uninstall_extension('@jupyterlab/python-tests')128 path = pjoin(self.app_dir, 'extensions', '*python_tests*.tgz')129 assert not glob.glob(path)130 assert '@jupyterlab/python-tests' not in _get_extensions(self.app_dir)131 def test_uninstall_core_extension(self):132 uninstall_extension('@jupyterlab/console-extension')133 app_dir = self.app_dir134 _ensure_package(app_dir)135 with open(pjoin(app_dir, 'staging', 'package.json')) as fid:136 data = json.load(fid)137 extensions = data['jupyterlab']['extensions']138 assert '@jupyterlab/console-extension' not in extensions139 install_extension('@jupyterlab/console-extension')140 _ensure_package(app_dir)141 with open(pjoin(app_dir, 'staging', 'package.json')) as fid:142 data = json.load(fid)143 extensions = data['jupyterlab']['extensions']144 assert '@jupyterlab/console-extension' in extensions145 def test_link_extension(self):146 link_package(self.source_dir)147 linked = _get_linked_packages().keys()148 assert '@jupyterlab/python-tests' in linked149 assert '@jupyterlab/python-tests' in _get_extensions(self.app_dir)150 def test_link_mime_renderer(self):151 link_package(self.mime_renderer_dir)152 linked = _get_linked_packages().keys()153 assert '@jupyterlab/mime-extension-test' in linked154 assert '@jupyterlab/mime-extension-test' in _get_extensions(self.app_dir)155 unlink_package('@jupyterlab/mime-extension-test')156 linked = _get_linked_packages().keys()157 assert '@jupyterlab/mime-extension-test' not in linked158 assert '@jupyterlab/mime-extension-test' not in _get_extensions(self.app_dir)159 def test_link_package(self):160 path = self.mock_package161 link_package(path)162 linked = _get_linked_packages().keys()163 with open(pjoin(path, 'package.json')) as fid:164 data = json.load(fid)165 assert data['name'] in linked166 assert not data['name'] in _get_extensions(self.app_dir)167 unlink_package(path)168 linked = _get_linked_packages().keys()169 assert not data['name'] in linked170 def test_link_incompatible(self):171 with pytest.raises(ValueError) as excinfo:172 install_extension(self.incompat_dir)173 assert 'Conflicting Dependencies' in str(excinfo.value)174 def test_unlink_package(self):175 target = self.source_dir176 link_package(target)177 unlink_package(target)178 linked = _get_linked_packages().keys()179 assert '@jupyterlab/python-tests' not in linked180 assert '@jupyterlab/python-tests' not in _get_extensions(self.app_dir)181 def test_list_extensions(self):182 install_extension(self.source_dir)183 list_extensions()184 def test_app_dir(self):185 app_dir = self.tempdir()186 install_extension(self.source_dir, app_dir)187 path = pjoin(app_dir, 'extensions', '*python-tests*.tgz')188 assert glob.glob(path)189 assert '@jupyterlab/python-tests' in _get_extensions(app_dir)190 uninstall_extension('@jupyterlab/python-tests', app_dir)191 path = pjoin(app_dir, 'extensions', '*python-tests*.tgz')192 assert not glob.glob(path)193 assert '@jupyterlab/python-tests' not in _get_extensions(app_dir)194 link_package(self.source_dir, app_dir)195 linked = _get_linked_packages(app_dir).keys()196 assert '@jupyterlab/python-tests' in linked197 unlink_package(self.source_dir, app_dir)198 linked = _get_linked_packages(app_dir).keys()199 assert '@jupyterlab/python-tests' not in linked200 def test_app_dir_use_sys_prefix(self):201 app_dir = self.tempdir()202 if os.path.exists(self.app_dir):203 os.removedirs(self.app_dir)204 install_extension(self.source_dir)205 path = pjoin(app_dir, 'extensions', '*python-tests*.tgz')206 assert not glob.glob(path)207 assert '@jupyterlab/python-tests' in _get_extensions(app_dir)208 def test_app_dir_shadowing(self):209 app_dir = self.tempdir()210 sys_dir = self.app_dir211 if os.path.exists(sys_dir):212 os.removedirs(sys_dir)213 install_extension(self.source_dir)214 sys_path = pjoin(sys_dir, 'extensions', '*python-tests*.tgz')215 assert glob.glob(sys_path)216 app_path = pjoin(app_dir, 'extensions', '*python-tests*.tgz')217 assert not glob.glob(app_path)218 assert '@jupyterlab/python-tests' in _get_extensions(app_dir)219 install_extension(self.source_dir, app_dir)220 assert glob.glob(app_path)221 assert '@jupyterlab/python-tests' in _get_extensions(app_dir)222 uninstall_extension('@jupyterlab/python-tests', app_dir)223 assert not glob.glob(app_path)224 assert glob.glob(sys_path)225 assert '@jupyterlab/python-tests' in _get_extensions(app_dir)226 uninstall_extension('@jupyterlab/python-tests', app_dir)227 assert not glob.glob(app_path)228 assert not glob.glob(sys_path)229 assert '@jupyterlab/python-tests' not in _get_extensions(app_dir)230 def test_build(self):231 install_extension(self.source_dir)232 build()233 # check staging directory.234 entry = pjoin(self.app_dir, 'staging', 'build', 'index.out.js')235 with open(entry) as fid:236 data = fid.read()237 assert '@jupyterlab/python-tests' in data238 # check static directory.239 entry = pjoin(self.app_dir, 'static', 'index.out.js')240 with open(entry) as fid:241 data = fid.read()242 assert '@jupyterlab/python-tests' in data243 def test_build_custom(self):...

Full Screen

Full Screen

extension_info.py

Source:extension_info.py Github

copy

Full Screen

...24 ext_data['alias'] = ext.alias25 ext_data['description'] = ext.__doc__26 ext_data['version'] = ext.version27 return ext_data28 def _get_extensions(self, context):29 """Filter extensions list based on policy."""30 discoverable_extensions = dict()31 for alias, ext in self.extension_info.get_extensions().iteritems():32 authorize = extensions.soft_extension_authorizer(33 'compute', 'v3:' + alias)34 if authorize(context, action='discoverable'):35 discoverable_extensions[alias] = ext36 else:37 LOG.debug("Filter out extension %s from discover list",38 alias)39 return discoverable_extensions40 @extensions.expected_errors(())41 def index(self, req):42 context = req.environ['nova.context']43 sorted_ext_list = sorted(44 self._get_extensions(context).iteritems())45 extensions = []46 for _alias, ext in sorted_ext_list:47 extensions.append(self._translate(ext))48 return dict(extensions=extensions)49 @extensions.expected_errors(404)50 def show(self, req, id):51 context = req.environ['nova.context']52 try:53 # NOTE(dprince): the extensions alias is used as the 'id' for show54 ext = self._get_extensions(context)[id]55 except KeyError:56 raise webob.exc.HTTPNotFound()57 return dict(extension=self._translate(ext))58class ExtensionInfo(extensions.V3APIExtensionBase):59 """Extension information."""60 name = "Extensions"61 alias = "extensions"62 version = 163 def get_resources(self):64 resources = [65 extensions.ResourceExtension(66 'extensions', ExtensionInfoController(self.extension_info),67 member_name='extension')]68 return resources...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful