How to use get_plugin method in Slash

Best Python code snippet using slash

test_plugin.py

Source:test_plugin.py Github

copy

Full Screen

...49@pytest.fixture50def build_deps(dep_workbench, dependent_object):51 """Get the build dependencies of a dependent_object.52 """53 core = dep_workbench.get_plugin('enaml.workbench.core')54 dep = core.invoke_command(ANALYSE, {'obj': dependent_object})55 return dep.dependencies56@pytest.fixture57def runtime_deps(dep_workbench, dependent_object):58 """Get the runtime dependencies of a dependent_object.59 """60 core = dep_workbench.get_plugin('enaml.workbench.core')61 dep = core.invoke_command(ANALYSE, {'obj': dependent_object,62 'dependencies': ['runtime']}63 )64 return dep.dependencies65# =============================================================================66# --- Analysing ---------------------------------------------------------------67# =============================================================================68def test_analysing_build(dep_workbench, dependent_object):69 """Test analysing only the build dependencies.70 """71 core = dep_workbench.get_plugin('enaml.workbench.core')72 dep = core.invoke_command(ANALYSE, {'obj': dependent_object})73 assert not dep.errors74 assert 'test' in dep.dependencies75 assert 'r' in dep.dependencies['test']76def test_analysing_build_from_config(dep_workbench):77 """Test analysing the build dependencies based on a ConfigObj.78 """79 core = dep_workbench.get_plugin('enaml.workbench.core')80 # nested field ensures that we skip object missing a dep_type81 dep = core.invoke_command(ANALYSE,82 {'obj': ConfigObj({'val': '1',83 'dep_type': 'test',84 'nested': {}})}85 )86 assert not dep.errors87 assert 'test' in dep.dependencies88 assert '1' in dep.dependencies['test']89def test_analysing_runtime(dep_workbench, dependent_object):90 """Test analysing only the runtime dependencies.91 """92 core = dep_workbench.get_plugin('enaml.workbench.core')93 dep = core.invoke_command(ANALYSE, {'obj': dependent_object,94 'dependencies': ['runtime']}95 )96 assert not dep.errors97 assert 'test_run_collect' in dep.dependencies98 assert 2 in dep.dependencies['test_run_collect']99def test_analysing_all(dep_workbench, dependent_object):100 """Test analysing all dependencies.101 """102 core = dep_workbench.get_plugin('enaml.workbench.core')103 b_dep, r_dep = core.invoke_command(ANALYSE,104 {'obj': dependent_object,105 'dependencies': ['build',106 'runtime']})107 assert not b_dep.errors and not r_dep.errors108 assert 'test' in b_dep.dependencies109 assert 'test_run_collect' in r_dep.dependencies110def test_handling_analysing_errors(dep_workbench, dependent_object):111 """Test handling errors occuring when analysing dependencies.112 """113 plugin = dep_workbench.get_plugin('exopy.app.dependencies')114 for b in plugin.build_deps.contributions.values():115 setattr(b, 'err', True)116 for r in plugin.run_deps_analysers.contributions.values():117 setattr(r, 'err', True)118 core = dep_workbench.get_plugin('enaml.workbench.core')119 b_dep, r_dep = core.invoke_command(ANALYSE,120 {'obj': dependent_object,121 'dependencies': ['build',122 'runtime']})123 assert 'test' in b_dep.errors and 'test_run_collect' in r_dep.errors124 assert b_dep.errors['test'].get('Test_object')125 assert r_dep.errors['test_run_collect'].get('Test_object')126def test_handling_analysing_exception_in_build(dep_workbench,127 dependent_object):128 """Test handling errors occuring when analysing dependencies.129 """130 plugin = dep_workbench.get_plugin('exopy.app.dependencies')131 for b in plugin.build_deps.contributions.values():132 setattr(b, 'exc', True)133 core = dep_workbench.get_plugin('enaml.workbench.core')134 b_dep, r_dep = core.invoke_command(ANALYSE,135 {'obj': dependent_object,136 'dependencies': ['build',137 'runtime']})138 assert 'test' in b_dep.errors139 assert 'unhandled' in b_dep.errors['test']140def test_handling_analysing_exception_in_runtime(dep_workbench,141 dependent_object):142 """Test handling errors occuring when analysing dependencies.143 """144 plugin = dep_workbench.get_plugin('exopy.app.dependencies')145 for r in plugin.run_deps_analysers.contributions.values():146 setattr(r, 'exc', True)147 core = dep_workbench.get_plugin('enaml.workbench.core')148 b_dep, r_dep = core.invoke_command(ANALYSE,149 {'obj': dependent_object,150 'dependencies': ['build',151 'runtime']})152 assert 'test_run' in r_dep.errors153 assert 'unhandled' in r_dep.errors['test_run']154def test_handling_missing_build_analyser(dep_workbench, dependent_object):155 """Test analysing the dependencies of an object whose dep_type match156 no known collector.157 """158 dependent_object.dep_type = 'new'159 core = dep_workbench.get_plugin('enaml.workbench.core')160 dep = core.invoke_command(ANALYSE, {'obj': dependent_object})161 assert 'new' in dep.errors162def test_handling_missing_runtime_analyser(dep_workbench, dependent_object):163 """Test analysing the dependencies of an object for which a runtime164 collector is missing.165 """166 plugin = dep_workbench.get_plugin('exopy.app.dependencies')167 for b in plugin.build_deps.contributions.values():168 setattr(b, 'run', ['dummy'])169 core = dep_workbench.get_plugin('enaml.workbench.core')170 dep = core.invoke_command(ANALYSE, {'obj': dependent_object,171 'dependencies': ['runtime']})172 assert 'runtime' in dep.errors and 'dummy' in dep.errors['runtime']173def test_handling_runtime_analyser_not_matching_a_collector(dep_workbench,174 dependent_object):175 """Test analysing the dependencies of an object for which a runtime176 collector is missing.177 """178 plugin = dep_workbench.get_plugin('exopy.app.dependencies')179 for b in plugin.build_deps.contributions.values():180 setattr(b, 'run', ['run_test2'])181 core = dep_workbench.get_plugin('enaml.workbench.core')182 dep = core.invoke_command(ANALYSE, {'obj': dependent_object,183 'dependencies': ['runtime']})184 assert 'runtime' in dep.errors and 'collector' in dep.errors['runtime']185# =============================================================================186# --- Validating --------------------------------------------------------------187# =============================================================================188def test_validating_build(dep_workbench, build_deps):189 """Test validating build dependencies.190 """191 core = dep_workbench.get_plugin('enaml.workbench.core')192 res, err = core.invoke_command(VALIDATE, {'kind': 'build',193 'dependencies': build_deps})194 assert res195def test_validating_runtime(dep_workbench, runtime_deps):196 """Test validating runtime dependencies.197 """198 core = dep_workbench.get_plugin('enaml.workbench.core')199 res, err = core.invoke_command(VALIDATE, {'kind': 'runtime',200 'dependencies': runtime_deps})201 assert res202def test_validating_with_wrong_kind(dep_workbench):203 """Test handling of incorrect kind argument.204 """205 core = dep_workbench.get_plugin('enaml.workbench.core')206 with pytest.raises(ValueError):207 res, err = core.invoke_command(VALIDATE, {'kind': 'test',208 'dependencies': {}})209def test_handling_validating_errors(dep_workbench, build_deps):210 """Test reporting errors.211 """212 build_deps['test'].add('t')213 core = dep_workbench.get_plugin('enaml.workbench.core')214 res, err = core.invoke_command(VALIDATE, {'kind': 'build',215 'dependencies': build_deps})216 assert not res217 assert 't' in err['test']218def test_handling_validating_exceptions(dep_workbench, build_deps):219 """Test dealing with unhandled exceptions.220 """221 plugin = dep_workbench.get_plugin('exopy.app.dependencies')222 for b in plugin.build_deps.contributions.values():223 setattr(b, 'exc', True)224 core = dep_workbench.get_plugin('enaml.workbench.core')225 res, err = core.invoke_command(VALIDATE, {'kind': 'build',226 'dependencies': build_deps})227 assert not res228def test_handling_missing_validator(dep_workbench, build_deps):229 """Test handling a missing validator230 """231 build_deps['dummy'] = set()232 core = dep_workbench.get_plugin('enaml.workbench.core')233 res, err = core.invoke_command(VALIDATE, {'kind': 'build',234 'dependencies': build_deps})235 assert not res236# =============================================================================237# --- Collecting --------------------------------------------------------------238# =============================================================================239def test_collecting_build(dep_workbench, build_deps):240 """Test collecting build dependencies.241 """242 core = dep_workbench.get_plugin('enaml.workbench.core')243 dep = core.invoke_command(COLLECT, {'kind': 'build',244 'dependencies': build_deps})245 assert dep.dependencies['test']['r'] is object246 assert not dep.errors247def test_collecting_runtime(dep_workbench, runtime_deps):248 """Test collecting runtime dependencies.249 """250 plugin = dep_workbench.get_plugin('exopy.app.dependencies')251 core = dep_workbench.get_plugin('enaml.workbench.core')252 dep = core.invoke_command(COLLECT, {'kind': 'runtime',253 'dependencies': runtime_deps,254 'owner': plugin.manifest.id})255 assert dep.dependencies['test_run_collect']['run'] == 1256 assert not dep.errors257def test_collecting_unavailable_runtime(dep_workbench, runtime_deps):258 """Test collecting unavailable runtimes.259 """260 plugin = dep_workbench.get_plugin('exopy.app.dependencies')261 core = dep_workbench.get_plugin('enaml.workbench.core')262 for r in plugin.run_deps_collectors.contributions.values():263 setattr(r, 'una', True)264 dep = core.invoke_command(COLLECT, {'kind': 'runtime',265 'dependencies': runtime_deps,266 'owner': plugin.manifest.id},267 )268 assert not dep.errors269 assert 'run_bis' in dep.dependencies['test_run_collect']270 assert 'run' not in dep.dependencies['test_run_collect']271 assert dep.unavailable['test_run_collect'] == {'run'}272def test_handling_collection_errors(dep_workbench, build_deps):273 """Test handling errors occuring when collecting dependencies.274 """275 build_deps['test'].add('t')276 core = dep_workbench.get_plugin('enaml.workbench.core')277 b_dep = core.invoke_command(COLLECT,278 {'kind': 'build',279 'dependencies': build_deps,280 'owner': 'exopy.test'})281 assert 't' in b_dep.errors['test']282def test_handling_collection_exceptions_in_build(dep_workbench, build_deps):283 """Test handling errors occuring when collecting dependencies.284 """285 plugin = dep_workbench.get_plugin('exopy.app.dependencies')286 for b in plugin.build_deps.contributions.values():287 setattr(b, 'exc', True)288 core = dep_workbench.get_plugin('enaml.workbench.core')289 b_dep = core.invoke_command(COLLECT,290 {'kind': 'build',291 'dependencies': build_deps,292 'owner': 'exopy.test'})293 assert 'test' in b_dep.errors294def test_handling_collection_exceptions_in_runtime(dep_workbench,295 runtime_deps):296 """Test handling errors occuring when collecting dependencies.297 """298 plugin = dep_workbench.get_plugin('exopy.app.dependencies')299 for r in plugin.run_deps_collectors.contributions.values():300 setattr(r, 'exc', True)301 core = dep_workbench.get_plugin('enaml.workbench.core')302 r_dep = core.invoke_command(COLLECT,303 {'kind': 'runtime',304 'dependencies': runtime_deps,305 'owner': 'exopy.test'})306 assert 'test_run_collect' in r_dep.errors307def test_handling_missing_caller(dep_workbench, runtime_deps):308 """Test handling a missing caller when runtime dependencies are309 requested.310 """311 core = dep_workbench.get_plugin('enaml.workbench.core')312 dep = core.invoke_command(COLLECT, {'kind': 'runtime',313 'dependencies': runtime_deps})314 assert 'owner' in dep.errors315def test_handling_missing_collector(dep_workbench, build_deps):316 """Test handling an unknown collector.317 """318 build_deps['dummy'] = set()319 core = dep_workbench.get_plugin('enaml.workbench.core')320 dep = core.invoke_command(COLLECT, {'kind': 'build',321 'dependencies': build_deps})322 assert 'dummy' in dep.errors323def test_collecting_with_wrong_kind(dep_workbench):324 """Test handling of incorrect kind argument.325 """326 core = dep_workbench.get_plugin('enaml.workbench.core')327 with pytest.raises(ValueError):328 res, err = core.invoke_command(COLLECT, {'kind': 'test',329 'dependencies': {}})330# =============================================================================331# --- Releasing ---------------------------------------------------------------332# =============================================================================333def test_releasing_runtimes(dep_workbench, runtime_deps):334 """Test releasing runtime dependencies.335 """336 plugin = dep_workbench.get_plugin('exopy.app.dependencies')337 core = dep_workbench.get_plugin('enaml.workbench.core')338 dep = core.invoke_command(COLLECT, {'kind': 'runtime',339 'dependencies': runtime_deps,340 'owner': plugin.manifest.id},341 )342 # Ensure that an unknown runtime won't crash343 dep.dependencies['rr'] = {}344 core.invoke_command(RELEASE,345 {'dependencies': dep.dependencies,346 'owner': plugin.manifest.id},347 )348 assert 'run' not in dep.dependencies['test_run_collect']349# =============================================================================350# --- API ---------------------------------------------------------------351# =============================================================================...

Full Screen

Full Screen

test_plugins.py

Source:test_plugins.py Github

copy

Full Screen

...30 self.future2s = '01 Jan 2101 00:00'31 page = api.create_page('page', 'page.html', 'en')32 page.rescan_placeholders() # create placeholders33 self.placeholder = page.placeholders.all()[0]34 def get_plugin(self, start, end):35 return TimedContentPlugin(36 timed_start=start,37 timed_end=end,38 )39 def test_plugin_no_start_no_end(self):40 plugin = self.get_plugin(None, None)41 self.assertTrue(plugin.is_visible)42 self.assertEqual(43 plugin.get_display(),44 'Always visible'45 )46 def test_form_no_start_no_end(self):47 plugin = self.get_plugin(None, None)48 plugin.clean()49 def test_plugin_start_in_past_no_end(self):50 plugin = self.get_plugin(self.past1, None)51 self.assertTrue(plugin.is_visible)52 self.assertEqual(53 plugin.get_display(),54 'Visible since {}'.format(self.past1s)55 )56 def test_form_start_in_past_no_end(self):57 plugin = self.get_plugin(self.past1, None)58 plugin.clean()59 def test_plugin_start_in_past_end_in_past(self):60 plugin = self.get_plugin(self.past1, self.past2)61 self.assertFalse(plugin.is_visible)62 self.assertEqual(63 plugin.get_display(),64 'Hidden since {}'.format(self.past2s)65 )66 def test_form_start_in_past_end_in_past(self):67 plugin = self.get_plugin(self.past1, self.past2)68 plugin.clean()69 def test_plugin_start_in_past_end_in_past_reversed(self):70 plugin = self.get_plugin(self.past2, self.past1)71 self.assertFalse(plugin.is_visible)72 self.assertEqual(73 plugin.get_display(),74 'Always hidden',75 )76 def test_form_start_in_past_end_in_past_reversed(self):77 plugin = self.get_plugin(self.past2, self.past1)78 with self.assertRaises(core.exceptions.ValidationError):79 plugin.clean()80 def test_plugin_no_start_end_in_past(self):81 plugin = self.get_plugin(None, self.past1)82 self.assertFalse(plugin.is_visible)83 self.assertEqual(84 plugin.get_display(),85 'Hidden since {}'.format(self.past1s)86 )87 def test_form_no_start_end_in_past(self):88 plugin = self.get_plugin(None, self.past1)89 plugin.clean()90 def test_plugin_start_in_past_end_in_future(self):91 plugin = self.get_plugin(self.past1, self.future1)92 self.assertTrue(plugin.is_visible)93 self.assertEqual(94 plugin.get_display(),95 'Visible since {} until {}'.format(self.past1s, self.future1s)96 )97 def test_form_start_in_past_end_in_future(self):98 plugin = self.get_plugin(self.past1, self.future1)99 plugin.clean()100 def test_plugin_start_in_future_no_end(self):101 plugin = self.get_plugin(self.future1, None)102 self.assertFalse(plugin.is_visible)103 self.assertEqual(104 plugin.get_display(),105 'Hidden until {}'.format(self.future1s)106 )107 def test_form_start_in_future_no_end(self):108 plugin = self.get_plugin(self.future1, None)109 plugin.clean()110 def test_plugin_start_in_future_end_in_past(self):111 plugin = self.get_plugin(self.future1, self.past1)112 self.assertFalse(plugin.is_visible)113 self.assertEqual(114 plugin.get_display(),115 'Always hidden'116 )117 def test_form_start_in_future_end_in_past(self):118 plugin = self.get_plugin(self.future1, self.past1)119 with self.assertRaises(core.exceptions.ValidationError):120 plugin.clean()121 def test_plugin_start_in_future_end_in_future(self):122 plugin = self.get_plugin(self.future1, self.future2)123 self.assertFalse(plugin.is_visible)124 self.assertEqual(125 plugin.get_display(),126 'Hidden until {}'.format(self.future1s)127 )128 def test_form_start_in_future_end_in_future(self):129 plugin = self.get_plugin(self.future1, self.future2)130 plugin.clean()131 def test_plugin_start_in_future_end_in_future_reversed(self):132 plugin = self.get_plugin(self.future2, self.future1)133 self.assertFalse(plugin.is_visible)134 self.assertEqual(135 plugin.get_display(),136 'Always hidden',137 )138 def test_form_start_in_future_end_in_future_reversed(self):139 plugin = self.get_plugin(self.future2, self.future1)140 with self.assertRaises(core.exceptions.ValidationError):141 plugin.clean()142 def test_plugin_no_start_end_in_future(self):143 plugin = self.get_plugin(None, self.future1)144 self.assertTrue(plugin.is_visible)145 self.assertEqual(146 plugin.get_display(),147 'Visible until {}'.format(self.future1s)148 )149 def test_form_no_start_end_in_future(self):150 plugin = self.get_plugin(None, self.future1)151 plugin.clean()152 def get_plugin_in_page(self, start, end):153 return api.add_plugin(154 placeholder=self.placeholder,155 plugin_type='TimedContent',156 language='en',157 position='last-child',158 timed_start=start,159 timed_end=end,160 )161 def test_get_short_description(self):162 plugin = self.get_plugin_in_page(None, None)163 self.assertEqual(164 plugin.get_short_description(),...

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 Slash 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