Best JavaScript code snippet using qawolf
load-plugins.spec.js
Source:load-plugins.spec.js
1/* global describe:true, it:true */2// Test setup:3import { expect, NOOP, sinon } from '../test-setup';4// Dependencies:5import fs from 'fs';6import module from 'module';7import path from 'path';8import * as tractorLogger from 'tractor-logger';9import { TractorError } from 'tractor-error-handler';10// Under test:11import { loadPlugins } from './load-plugins';12describe('tractor-plugin-loader:', () => {13 describe('load-plugins:', () => {14 it('should do nothing if there is not any installed plugins', () => {15 let nodeModules = [];16 sinon.stub(fs, 'readdirSync').returns(nodeModules);17 sinon.stub(tractorLogger, 'info');18 let plugins = loadPlugins();19 expect(plugins.length).to.equal(0);20 fs.readdirSync.restore();21 tractorLogger.info.restore();22 });23 it('should create a plugin for each installed plugin', () => {24 let nodeModules = ['tractor-plugin-test'];25 let pluginModule = {};26 sinon.stub(fs, 'readdirSync').returns(nodeModules);27 sinon.stub(module, '_load').returns(pluginModule);28 sinon.stub(tractorLogger, 'info');29 let plugins = loadPlugins();30 expect(plugins.length).to.equal(1);31 expect(pluginModule.fullName).to.equal('tractor-plugin-test');32 expect(pluginModule.name).to.equal('test');33 fs.readdirSync.restore();34 module._load.restore();35 tractorLogger.info.restore();36 });37 it('should create a plugin for an ES2015 module', () => {38 let nodeModules = ['tractor-plugin-test'];39 let pluginModule = {40 default: {}41 };42 sinon.stub(fs, 'readdirSync').returns(nodeModules);43 sinon.stub(module, '_load').returns(pluginModule);44 sinon.stub(tractorLogger, 'info');45 let plugins = loadPlugins();46 expect(plugins.length).to.equal(1);47 fs.readdirSync.restore();48 module._load.restore();49 tractorLogger.info.restore();50 });51 it('should throw if the plugin cannot be loaded', () => {52 let nodeModules = ['tractor-plugin-test'];53 sinon.stub(fs, 'readdirSync').returns(nodeModules);54 sinon.stub(module, '_load').throws(new Error());55 sinon.stub(tractorLogger, 'info');56 expect(() => {57 loadPlugins();58 }).to.throw(TractorError, `could not require 'tractor-plugin-test'`);59 fs.readdirSync.restore();60 module._load.restore();61 tractorLogger.info.restore();62 });63 it('should decorate the `description` with display values', () => {64 let nodeModules = ['tractor-plugin-test-plugin'];65 let pluginModule = {};66 sinon.stub(fs, 'readdirSync').returns(nodeModules);67 sinon.stub(module, '_load').returns(pluginModule);68 sinon.stub(tractorLogger, 'info');69 let plugins = loadPlugins();70 let [test] = plugins;71 expect(test.description.name).to.equal('Test Plugin');72 expect(test.description.variableName).to.equal('testPlugin');73 expect(test.description.url).to.equal('test-plugin');74 fs.readdirSync.restore();75 module._load.restore();76 tractorLogger.info.restore();77 });78 it('should not overwrite an existing `description`', () => {79 let nodeModules = ['tractor-plugin-test-plugin'];80 let pluginModule = {81 description: {}82 };83 sinon.stub(fs, 'readdirSync').returns(nodeModules);84 sinon.stub(module, '_load').returns(pluginModule);85 sinon.stub(tractorLogger, 'info');86 let plugins = loadPlugins();87 let [test] = plugins;88 expect(test.description).to.equal(pluginModule.description);89 fs.readdirSync.restore();90 module._load.restore();91 tractorLogger.info.restore();92 });93 it('should decorate the `description` with the version', () => {94 let nodeModules = ['tractor-plugin-test-plugin'];95 let pluginModule = {};96 let pluginPackage = {97 version: '0.1.0'98 };99 sinon.stub(process, 'cwd').returns('');100 sinon.stub(fs, 'readdirSync').returns(nodeModules);101 sinon.stub(module, '_load')102 .withArgs('node_modules/tractor-plugin-test-plugin').returns(pluginModule)103 .withArgs('node_modules/tractor-plugin-test-plugin/package.json').returns(pluginPackage);104 sinon.stub(tractorLogger, 'info');105 let plugins = loadPlugins();106 let [test] = plugins;107 expect(test.description.version).to.equal('0.1.0');108 process.cwd.restore();109 fs.readdirSync.restore();110 module._load.restore();111 tractorLogger.info.restore();112 });113 it('should have a default `create` function that is a noop', () => {114 let nodeModules = ['tractor-plugin-test'];115 let pluginModule = {};116 sinon.stub(fs, 'readdirSync').returns(nodeModules);117 sinon.stub(module, '_load').returns(pluginModule);118 sinon.stub(tractorLogger, 'info');119 let plugins = loadPlugins();120 let [test] = plugins;121 expect(() => {122 test.create();123 }).to.not.throw();124 fs.readdirSync.restore();125 module._load.restore();126 tractorLogger.info.restore();127 });128 it('should not overwrite an existing `create` function', () => {129 let nodeModules = ['tractor-plugin-test'];130 let pluginModule = {131 create: NOOP132 };133 sinon.stub(fs, 'readdirSync').returns(nodeModules);134 sinon.stub(module, '_load').returns(pluginModule);135 sinon.stub(pluginModule, 'create');136 sinon.stub(tractorLogger, 'info');137 let plugins = loadPlugins();138 let [test] = plugins;139 test.create();140 expect(pluginModule.create).to.have.been.called();141 fs.readdirSync.restore();142 module._load.restore();143 tractorLogger.info.restore();144 });145 it('should have a default `init` function that is a noop', () => {146 let nodeModules = ['tractor-plugin-test'];147 let pluginModule = {};148 sinon.stub(fs, 'readdirSync').returns(nodeModules);149 sinon.stub(module, '_load').returns(pluginModule);150 sinon.stub(tractorLogger, 'info');151 let plugins = loadPlugins();152 let [test] = plugins;153 expect(() => {154 test.init();155 }).to.not.throw();156 fs.readdirSync.restore();157 module._load.restore();158 tractorLogger.info.restore();159 });160 it('should not overwrite an existing `init` function', () => {161 let nodeModules = ['tractor-plugin-test'];162 let pluginModule = {163 init: NOOP164 };165 sinon.stub(fs, 'readdirSync').returns(nodeModules);166 sinon.stub(module, '_load').returns(pluginModule);167 sinon.stub(pluginModule, 'init');168 sinon.stub(tractorLogger, 'info');169 let plugins = loadPlugins();170 let [test] = plugins;171 test.init();172 expect(pluginModule.init).to.have.been.called();173 fs.readdirSync.restore();174 module._load.restore();175 tractorLogger.info.restore();176 });177 it('should have a default `plugin` function that is a noop', () => {178 let nodeModules = ['tractor-plugin-test'];179 let pluginModule = {};180 sinon.stub(fs, 'readdirSync').returns(nodeModules);181 sinon.stub(module, '_load').returns(pluginModule);182 sinon.stub(tractorLogger, 'info');183 let plugins = loadPlugins();184 let [test] = plugins;185 expect(() => {186 test.plugin();187 }).to.not.throw();188 fs.readdirSync.restore();189 module._load.restore();190 tractorLogger.info.restore();191 });192 it('should not overwrite an existing `plugin` function', () => {193 let nodeModules = ['tractor-plugin-test'];194 let pluginModule = {195 plugin: NOOP196 };197 sinon.stub(fs, 'readdirSync').returns(nodeModules);198 sinon.stub(module, '_load').returns(pluginModule);199 sinon.stub(pluginModule, 'plugin');200 sinon.stub(tractorLogger, 'info');201 let plugins = loadPlugins();202 let [test] = plugins;203 test.plugin();204 expect(pluginModule.plugin).to.have.been.called();205 fs.readdirSync.restore();206 module._load.restore();207 tractorLogger.info.restore();208 });209 it('should have a default `run` function that is a noop', () => {210 let nodeModules = ['tractor-plugin-test'];211 let pluginModule = {};212 sinon.stub(fs, 'readdirSync').returns(nodeModules);213 sinon.stub(module, '_load').returns(pluginModule);214 sinon.stub(tractorLogger, 'info');215 let plugins = loadPlugins();216 let [test] = plugins;217 expect(() => {218 test.run();219 }).to.not.throw();220 fs.readdirSync.restore();221 module._load.restore();222 tractorLogger.info.restore();223 });224 it('should not overwrite an existing `run` function', () => {225 let nodeModules = ['tractor-plugin-test'];226 let pluginModule = {227 run: NOOP228 };229 sinon.stub(fs, 'readdirSync').returns(nodeModules);230 sinon.stub(module, '_load').returns(pluginModule);231 sinon.stub(pluginModule, 'run');232 sinon.stub(tractorLogger, 'info');233 let plugins = loadPlugins();234 let [test] = plugins;235 test.run();236 expect(pluginModule.run).to.have.been.called();237 fs.readdirSync.restore();238 module._load.restore();239 tractorLogger.info.restore();240 });241 it('should have a default `serve` function that is a noop', () => {242 let nodeModules = ['tractor-plugin-test'];243 let pluginModule = {};244 sinon.stub(fs, 'readdirSync').returns(nodeModules);245 sinon.stub(module, '_load').returns(pluginModule);246 sinon.stub(tractorLogger, 'info');247 let plugins = loadPlugins();248 let [test] = plugins;249 expect(() => {250 test.serve();251 }).to.not.throw();252 fs.readdirSync.restore();253 module._load.restore();254 tractorLogger.info.restore();255 });256 it('should not overwrite an existing `serve` function', () => {257 let nodeModules = ['tractor-plugin-test'];258 let pluginModule = {259 serve: NOOP260 };261 sinon.stub(fs, 'readdirSync').returns(nodeModules);262 sinon.stub(module, '_load').returns(pluginModule);263 sinon.stub(pluginModule, 'serve');264 sinon.stub(tractorLogger, 'info');265 let plugins = loadPlugins();266 let [test] = plugins;267 test.serve();268 expect(pluginModule.serve).to.have.been.called();269 fs.readdirSync.restore();270 module._load.restore();271 tractorLogger.info.restore();272 });273 it('should have a default `upgrade` function that is a noop', () => {274 let nodeModules = ['tractor-plugin-test'];275 let pluginModule = {};276 sinon.stub(fs, 'readdirSync').returns(nodeModules);277 sinon.stub(module, '_load').returns(pluginModule);278 sinon.stub(tractorLogger, 'info');279 let plugins = loadPlugins();280 let [test] = plugins;281 expect(() => {282 test.upgrade();283 }).to.not.throw();284 fs.readdirSync.restore();285 module._load.restore();286 tractorLogger.info.restore();287 });288 it('should not overwrite an existing `upgrade` function', () => {289 let nodeModules = ['tractor-plugin-test'];290 let pluginModule = {291 upgrade: NOOP292 };293 sinon.stub(fs, 'readdirSync').returns(nodeModules);294 sinon.stub(module, '_load').returns(pluginModule);295 sinon.stub(pluginModule, 'upgrade');296 sinon.stub(tractorLogger, 'info');297 let plugins = loadPlugins();298 let [test] = plugins;299 test.upgrade();300 expect(pluginModule.upgrade).to.have.been.called();301 fs.readdirSync.restore();302 module._load.restore();303 tractorLogger.info.restore();304 });305 it('should try to load the UI bundle and set the `hasUI` flag to true if it works', () => {306 let nodeModules = ['tractor-plugin-test'];307 let pluginModule = {};308 sinon.stub(fs, 'accessSync').returns(true);309 sinon.stub(fs, 'readdirSync').returns(nodeModules);310 sinon.stub(module, '_load').returns(pluginModule);311 sinon.stub(process, 'cwd').returns('.');312 sinon.stub(tractorLogger, 'info');313 let plugins = loadPlugins();314 let [test] = plugins;315 expect(test.script).to.equal(path.join('node_modules', 'tractor-plugin-test', 'dist', 'client', 'bundle.js'));316 expect(test.description.hasUI).to.equal(true);317 fs.accessSync.restore();318 fs.readdirSync.restore();319 module._load.restore();320 process.cwd.restore();321 tractorLogger.info.restore();322 });323 it('should try to load the UI bundle and set the `hasUI` flag to false if it fails', () => {324 let nodeModules = ['tractor-plugin-test'];325 let pluginModule = {};326 sinon.stub(fs, 'accessSync').throws(new Error());327 sinon.stub(fs, 'readdirSync').returns(nodeModules);328 sinon.stub(module, '_load').returns(pluginModule);329 sinon.stub(process, 'cwd').returns('.');330 sinon.stub(tractorLogger, 'info');331 let plugins = loadPlugins();332 let [test] = plugins;333 expect(test.description.hasUI).to.equal(false);334 fs.accessSync.restore();335 fs.readdirSync.restore();336 module._load.restore();337 process.cwd.restore();338 tractorLogger.info.restore();339 });340 });...
test_factory.py
Source:test_factory.py
...38 self.assertEqual(ldr.catalog, {})39 @patch('builtins.__import__')40 @patch('os.path.isdir')41 @patch('os.listdir')42 def test__load(self, _listdir, _isdir, _import):43 listing = [44 ['p1', Mock(__name__='p1', PROVIDES=['A', 'B'])],45 ['p2', Mock(__name__='p2', PROVIDES=['C', 'D'])],46 ['p3', Mock(__name__='p3', PROVIDES=['E', 'F'])],47 ['p4', Mock(__name__='p4', PROVIDES=['G', 'H'])],48 ['p5', AttributeError],49 ['p6', ImportError],50 ['f1', None],51 ]52 loaded = self._loaded(listing)53 def isdir(p):54 return os.path.basename(p).startswith('p')55 _listdir.return_value = [p[0] for p in listing]56 _isdir.side_effect = isdir57 _import.side_effect = [p[1] for p in listing]58 _list, catalog = Loader._load()59 self.assertEqual(_list, loaded[0])60 self.assertEqual(catalog, loaded[1])61 def _loaded(self, listing):62 _list = []63 catalog = {}64 for name, pkg in listing:65 if not name.startswith('p'):66 continue67 if not isinstance(pkg, Mock):68 continue69 _list.append(pkg)70 catalog[name] = pkg71 catalog['.'.join((PACKAGE, name))] = pkg72 for c in pkg.PROVIDES:73 catalog[c] = pkg74 return _list, catalog75 @patch('gofer.messaging.adapter.factory.Loader._load')76 def test_load(self, _load):77 _load.return_value = ([], {})78 ldr = Loader()79 _list, catalog = ldr.load()80 _load.assert_called_with()81 self.assertEqual(_list, _load.return_value[0])82 self.assertEqual(catalog, _load.return_value[1])83 self.assertEqual(ldr.list, _load.return_value[0])84 self.assertEqual(ldr.catalog, _load.return_value[1])85 @patch('gofer.messaging.adapter.factory.Loader._load')86 def test_already_loaded(self, _load):87 ldr = Loader()88 ldr.list = [1, 2]89 ldr.catalog = {'A': 1, 'B': 2}90 _list, catalog = ldr.load()...
test_decode_data.py
Source:test_decode_data.py
...4class TestDecodeData(unittest.TestCase):5 """Functionally tests the logic of _parse_values6 Focuses on string values, to ignore conversion logic.7 """8 def _load(self, data, n_attribs=1):9 txt = textwrap.dedent('''10 @RELATION testing11 {attribs}12 @DATA13 {data}14 ''').format(attribs='\n'.join('@ATTRIBUTE x%d STRING' % i15 for i in range(n_attribs)),16 data=data)17 return arff.load(txt)['data']18 def assertLoadsAs(self, data, expected, n_attribs=1):19 result = self._load(data, n_attribs)20 self.assertListEqual(result, expected)21 def test_quotes(self):22 self.assertLoadsAs("""'ENACT.NOGOPMAJ,2017'""",23 [['ENACT.NOGOPMAJ,2017']])24 self.assertLoadsAs('''"ENACT.NOGOPMAJ,2017"''',25 [['ENACT.NOGOPMAJ,2017']])26 self.assertLoadsAs(''' 'A','B' , '"','C,D' ''',27 [['A', 'B', '"', 'C,D']],28 n_attribs=4)29 def test_quotes_sparse(self):30 self.assertLoadsAs("""{0 'ENACT.NOGOPMAJ,2017'}""",31 [['ENACT.NOGOPMAJ,2017']])32 self.assertLoadsAs('''{0 "ENACT.NOGOPMAJ,2017"}''',33 [['ENACT.NOGOPMAJ,2017']])...
loader.js
Source:loader.js
1(function(w) {2 var _load = {};3 _load.isMobile = /mobile/i.test(navigator.userAgent);4 _load.isIE = (/MSIE/i.test(navigator.userAgent));5 _load.isDevel = true;6 _load.t = (_load.isDevel) ? '' : 'min.';7 _load.s3 = (_load.isDevel) ? '' : 'http://istitchapp.s3-website-us-east-1.amazonaws.com/pub';8 /**9 * Import Javascript10 */11 _load.requireScript = function(f, c) {12 var head = document.getElementsByTagName("head")[0];13 var script = document.createElement('script');14 var cb = (c) ? c : function() {15 };16 script.src = '' + f;17 script.type = 'text/javascript';18 script.onload = cb;19 script.onreadystatechange = function() {20 if (this.readyState == 'complete') {21 cb();22 }23 }24 head.appendChild(script);25 //head.parentNode.insertBefore(script);26 }27 /**28 * Import CSS29 */30 _load.requireStyle = function(f, c) {31 var head = document.getElementsByTagName("head")[0];32 var style = document.createElement('link');33 var cb = (c) ? c : function() {34 };35 style.href = '' + f;36 style.rel = 'stylesheet';37 style.onload = cb;38 style.onreadystatechange = function() {39 if (this.readyState == 'complete') {40 cb();41 }42 }43 head.appendChild(style);44 //head.parentNode.insertBefore(style);45 }46 /**47 * Console48 */49 if ( typeof console == "undefined") {50 this.console = {51 log : function() {52 }53 };54 }55 /**56 * Simple mobile / desktop switch57 */58 if (_load.isMobile) {59 //MOBILE60 /**61 * Android issue62 * Don't use callback in css files or you you're gonna have a bad time!63 */64 _load.requireStyle(_load.s3+'/css/mobile.' + _load.t + 'css', false);65 _load.requireStyle(_load.s3+'/css/themes/my-custom-theme.min.css', false);66 _load.requireStyle('http://code.jquery.com/mobile/1.3.0/jquery.mobile.structure-1.3.0.min.css', false);67 //_load.requireStyle('http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css',false);68 _load.requireScript('http://code.jquery.com/jquery-1.9.1.min.js', function() {69 _load.requireScript('http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js', function() {70 _load.requireScript(_load.s3+'/js/stitch.' + _load.t + 'js', function() {71 _load.requireScript(_load.s3+'/js/mobile.' + _load.t + 'js', false);72 });73 });74 });75 /*_load.requireScript('/js/lib/binaryajax.min.js', function() {76 _load.requireScript('/js/lib/canvasResize.min.js', function() {77 _load.requireScript('/js/lib/exif.min.js', function() {78 _load.requireScript('/js/stitch.' + _load.t + 'js', false);79 });80 });81 });*/82 _load.requireScript(_load.s3+'/js/lib/canvasResizeAll.min.js', false);83 } else {84 //DESKTOP85 _load.requireStyle('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css', function() {86 _load.requireStyle('http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css', function() {87 _load.requireStyle(_load.s3+'/css/desktop.' + _load.t + 'css', false);88 });89 });90 _load.requireScript('http://code.jquery.com/jquery-1.9.1.min.js', function() {91 _load.requireScript('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js', function() {92 _load.requireScript(_load.s3+'/js/lib/routie/routie.min.js', function() {93 _load.requireScript(_load.s3+'/js/stitch.' + _load.t + 'js', function() {94 _load.requireScript(_load.s3+'/js/desktop.' + _load.t + 'js', function() {95 });96 });97 });98 });99 });100 //IF MSIE than there is no need to load libs for image processing :(101 if (!(_load.isIE)) {102 /*_load.requireScript('/js/lib/binaryajax.min.js', function() {103 _load.requireScript('/js/lib/canvasResize.js', function() {104 _load.requireScript('/js/lib/exif.min.js', function() {105 });106 });107 });*/108 _load.requireScript(_load.s3+'/js/lib/canvasResizeAll.min.js', false);109 }110 }111})(window);112/**113 * GOOGLE ANALYTICS114 */115var _gaq = _gaq || [];116_gaq.push(['_setAccount', (/istitchapp/i.test(document.location)) ? 'UA-39213885-1' : 'UA-XXXXX-Y']);117_gaq.push(['_setCustomVar', 1, 'APP', (/mobile/i.test(navigator.userAgent)) ? 'Mobile' : 'Desktop', 1]);118_gaq.push(['_trackPageview']);119(function() {120 var ga = document.createElement('script');121 ga.type = 'text/javascript';122 ga.async = true;123 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';124 var s = document.getElementsByTagName('script')[0];125 s.parentNode.insertBefore(ga, s);...
Resource_Picture.js
Source:Resource_Picture.js
1/*2 æ3*/4function @@_Load(url)5{6 LOGPOS;7 Loading++;8 var image = new Image();9 image.src = url;10 image.onload = function()11 {12 LOGPOS;13 Loading--;14 };15 image.onerror = function()16 {17 error;18 };19 return image;20}21// ±±©çeíæ22// vtBNX23// P_ ... æ24var P_Dummy = @@_Load(Resources.General__Dummy_png); // TvƵÄL[v25// wiÍ [ ú, [û, é(_), é(Á) ] ÌÅ éB26var P_wi_©î =27[28 @@_Load(Resources.Á¸___house_enterance_interior_a_jpg),29 @@_Load(Resources.Á¸___house_enterance_interior_b_jpg),30 @@_Load(Resources.Á¸___house_enterance_interior_c_jpg),31 @@_Load(Resources.Á¸___house_enterance_interior_d_jpg),32];33var P_wi_©º =34[35 @@_Load(Resources.Á¸___house_room_weekly_apartment_a_jpg),36 @@_Load(Resources.Á¸___house_room_weekly_apartment_b_jpg),37 @@_Load(Resources.Á¸___house_room_weekly_apartment_c_jpg),38 @@_Load(Resources.Á¸___house_room_weekly_apartment_d_jpg),39];40var P_wi_©îgC =41[42 @@_Load(Resources.Á¸___house_toilet_a_jpg),43 @@_Load(Resources.Á¸___house_toilet_b_jpg),44 @@_Load(Resources.Á¸___house_toilet_c_jpg),45 @@_Load(Resources.Á¸___house_toilet_d_jpg),46];47var P_wi_wZLº =48[49 @@_Load(Resources.Á¸___school_corridor_a_jpg),50 @@_Load(Resources.Á¸___school_corridor_b_jpg),51 @@_Load(Resources.Á¸___school_corridor_c_jpg),52 @@_Load(Resources.Á¸___school_corridor_d_jpg),53];54var @@_XߺA__ = @@_Load(Resources.Á¸___school_dressing_room_a_jpg); // x`Lè__55var @@_XߺA_Á = @@_Load(Resources.Á¸___school_dressing_room_b_jpg); // x`Lè_Á56var @@_XߺB__ = @@_Load(Resources.Á¸___school_dressing_room_c_jpg); // x`³µ__57var @@_XߺB_Á = @@_Load(Resources.Á¸___school_dressing_room_d_jpg); // x`³µ_Á58var P_wi_XߺA = // x`Lè59[60 @@_XߺA__,61 @@_XߺA__,62 @@_XߺA__,63 @@_XߺA_Á,64];65var P_wi_XߺB = // x`³µ66[67 @@_XߺB__,68 @@_XߺB__,69 @@_XߺB__,70 @@_XߺB_Á,71];72var P_wi_Zå =73[74 @@_Load(Resources.Á¸___school_gate_a_jpg),75 @@_Load(Resources.Á¸___school_gate_b_jpg),76 @@_Load(Resources.Á¸___school_gate_c_jpg),77 @@_Load(Resources.Á¸___school_gate_d_jpg),78];79var P_wi_ÌçÙ =80[81 @@_Load(Resources.Á¸___school_gym_a_jpg),82 @@_Load(Resources.Á¸___school_gym_b_jpg),83 @@_Load(Resources.Á¸___school_gym_c_jpg),84 @@_Load(Resources.Á¸___school_gym_d_jpg),85];86var P_wi_ö =87[88 @@_Load(Resources.Á¸___town_park_a_jpg),89 @@_Load(Resources.Á¸___town_park_b_jpg),90 @@_Load(Resources.Á¸___town_park_c_jpg),91 @@_Load(Resources.Á¸___town_park_d_jpg),...
api.js
Source:api.js
...9 baseURL,10 timeout,11 });12 }13 async _load(url, options) {14 const response = await this._http.request({url, ...options});15 return response.data;16 }17 getArticles({offset, limit, needComments, categoryId} = {}) {18 return this._load(`/articles`, {19 params: {offset, limit, needComments, categoryId},20 });21 }22 getCommentedArticles({limit} = {}) {23 return this._load(`/articles/most-commented`, {24 params: {limit},25 });26 }27 getArticle(id, {needComments, count} = {}) {28 return this._load(`/articles/${id}`, {params: {needComments, count}});29 }30 search(query) {31 return this._load(`/search`, {params: {query}});32 }33 async getCategories({needCount} = {}) {34 return this._load(`/categories`, {params: {needCount}});35 }36 async createArticle(data) {37 return this._load(`/articles`, {38 method: `POST`,39 data,40 });41 }42 async editArticle(id, data) {43 return this._load(`/articles/${id}`, {44 method: `PUT`,45 data,46 });47 }48 async createComment(id, data) {49 return this._load(`/articles/${id}/comments`, {50 method: `POST`,51 data,52 });53 }54 createUser(data) {55 return this._load(`/user`, {56 method: `POST`,57 data,58 });59 }60 auth(email, password) {61 return this._load(`/user/auth`, {62 method: `POST`,63 data: {email, password},64 });65 }66 getComments({limit, needArticles}) {67 return this._load(`/comments`, {params: {limit, needArticles}});68 }69 getCategory(id) {70 return this._load(`/categories/${id}`);71 }72 deleteArticle(id) {73 return this._load(`/articles/${id}`, {74 method: `DELETE`75 });76 }77 createCategory(data) {78 return this._load(`/categories`, {79 method: `POST`,80 data,81 });82 }83 editCategory(id, data) {84 return this._load(`/categories/${id}`, {85 method: `PUT`,86 data,87 });88 }89 deleteCategory(id) {90 return this._load(`/categories/${id}`, {91 method: `DELETE`92 });93 }94 deleteComment(id) {95 return this._load(`/comments/${id}`, {96 method: `DELETE`97 });98 }99}100const defaultAPI = new API(defaultUrl, TIMEOUT);101module.exports = {102 API,103 getAPI: () => defaultAPI,...
__init__.py
Source:__init__.py
...7 import pkg_resources8 _load = pkg_resources.resource_stream9from gzip import GzipFile10def _use_vendored_psims_obo():11 return GzipFile(fileobj=_load(__name__, "psi-ms.obo.gz"))12def _use_vendored_psimod_obo():13 return GzipFile(fileobj=_load(__name__, "psi-mod.obo.gz"))14def _use_vendored_unit_obo():15 return GzipFile(fileobj=_load(__name__, "unit.obo.gz"))16def _use_vendored_pato_obo():17 return GzipFile(fileobj=_load(__name__, "pato.obo.gz"))18def _use_vendored_unimod_xml():19 return GzipFile(fileobj=_load(__name__, "unimod_tables.xml.gz"))20def _use_vendored_xlmod_obo():21 return GzipFile(fileobj=_load(__name__, "XLMOD.obo.gz"))22def _use_vendored_bto_obo():23 return GzipFile(fileobj=_load(__name__, "bto.obo.gz"))24def _use_vendored_go_obo():25 return GzipFile(fileobj=_load(__name__, "go.obo.gz"))26def _use_vendored_gno_obo():27 return GzipFile(fileobj=_load(__name__, "gno.obo.gz"))28def version_table():29 fh = _load(__name__, "record.json")30 stream = io.TextIOWrapper(fh, 'utf8')...
Using AI Code Generation
1const qawolf = require("qawolf");2async function test() {3 const browser = await qawolf.launch();4 const context = await browser.newContext();5 await context.close();6 await browser.close();7}8test();9{10 "scripts": {11 },12 "dependencies": {13 }14}15{16 "dependencies": {17 "qawolf": {18 "requires": {19 }20 }21 }22}
Using AI Code Generation
1const { _load } = require('qawolf');2(async () => {3 const browser = await _load('chrome', 'test');4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.close();7 await context.close();8 await browser.close();9})();10{11 {12 }13}14const browser = await qawolf.launch();15const context = await browser.newContext();16const browser = await qawolf.launch();17const browserVersion = browser.version();18const browser = await qawolf.launch();19const browserName = browser.name();20const browser = await qawolf.launch();21const context = await browser.newContext();22const browser = await qawolf.launch();23const pages = await browser.pages();24const browser = await qawolf.launch();25const context = await browser.defaultContext();26const browser = await qawolf.launch();
Using AI Code Generation
1const { _load } = require("qawolf");2const { chromium } = require("playwright");3const browser = await chromium.launch();4const context = await browser.newContext();5await _load(context, "test");6await context.close();7await browser.close();8const { _load } = require("qawolf");9const { chromium } = require("playwright");10const browser = await chromium.launch();11const context = await browser.newContext();12await _load(context, "test");13await context.close();14await browser.close();15const { _load } = require("qawolf");16const { chromium } = require("playwright");17const browser = await chromium.launch();18const context = await browser.newContext();19await _load(context, "test");20await context.close();21await browser.close();22const { _load } = require("qawolf");23const { chromium } = require("playwright");24const browser = await chromium.launch();25const context = await browser.newContext();26await _load(context, "test");27await context.close();28await browser.close();29const { _load } = require("qawolf");30const { chromium } = require("playwright");31const browser = await chromium.launch();32const context = await browser.newContext();33await _load(context, "test");34await context.close();35await browser.close();36const { _load } = require("qawolf");37const { chromium } = require("playwright");38const browser = await chromium.launch();39const context = await browser.newContext();40await _load(context, "test");41await context.close();42await browser.close();
Using AI Code Generation
1const qawolf = require("qawolf");2qawolf._load({3 launchOptions: { headless: false },4});5const qawolf = require("qawolf");6qawolf._load({7 launchOptions: { headless: false },8});9const qawolf = require("qawolf");10qawolf._load({11 launchOptions: { headless: false },12});13const qawolf = require("qawolf");14qawolf._load({15 launchOptions: { headless: false },16});17const qawolf = require("qawolf");18qawolf._load({19 launchOptions: { headless: false },20});21const qawolf = require("qawolf");22qawolf._load({23 launchOptions: { headless: false },24});25const qawolf = require("qawolf");26qawolf._load({
Using AI Code Generation
1const qawolf = require("qawolf");2const browser = await qawolf.launch();3const context = await browser.newContext();4const page = await context.newPage();5await qawolf.register(page);6await page._click("button:nth-of-type(1)");7await page._type("input[name='password']", "123");8await page._click("button:nth-of-type(2)");9await qawolf.stopVideos();10await browser.close();11const { test, expect } = require("@playwright/test");12const { _load, _click, _type } = require("./test");13test("test", async ({ page }) => {14 await _click(page, "button:nth-of-type(1)");15 await _type(page, "input[name='password']", "123");16 await _click(page, "button:nth-of-type(2)");17});18{19 "scripts": {20 },21 "devDependencies": {22 }23}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!